Skip to content

Commit 35f4cb4

Browse files
committed
fix: 인증방식 requiresAuth: true 플래그로 변경
1 parent 1bca233 commit 35f4cb4

File tree

3 files changed

+11
-14
lines changed

3 files changed

+11
-14
lines changed

apps/next-client/src/app/community/[id]/edit/page.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import { ERROR_MESSAGES } from '@/constants/errors';
1111
export default function EditPostPage({ params }: { params: { id: string } }) {
1212
const { data: session } = useSession();
1313
const userId = session?.user?.id;
14-
const accessToken = session?.user?.accessToken || '';
1514

1615
if (!userId) {
1716
throw new Error(ERROR_MESSAGES.LOGIN_REQUIRED);
@@ -20,7 +19,7 @@ export default function EditPostPage({ params }: { params: { id: string } }) {
2019
return (
2120
<ErrorBoundary>
2221
<Suspense fallback={<LoadingSpinner />}>
23-
<EditPostContent params={params} userId={userId} accessToken={accessToken} />
22+
<EditPostContent params={params} userId={userId} />
2423
</Suspense>
2524
</ErrorBoundary>
2625
);

apps/next-client/src/components/community/EditPostContent.tsx

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,18 @@ import 'react-quill/dist/quill.snow.css';
77
import type Quill from 'quill';
88
import { axiosInstance } from '@/services/common/axiosInstance';
99
import { API_URLS } from '@/constants/urls';
10-
import Cookies from 'js-cookie';
1110
import { ALERT_MESSAGES } from '@/constants/alertMessage';
1211

1312
const ReactQuill = dynamic(() => import('react-quill'), { ssr: false });
1413

1514
interface EditPostContentProps {
1615
params: { id: string };
1716
userId: string;
18-
accessToken: string;
1917
}
2018

21-
export default function EditPostContent({ params, userId, accessToken }: EditPostContentProps) {
19+
export default function EditPostContent({ params, userId }: EditPostContentProps) {
2220
const { id } = params;
23-
const { title, setTitle, content, setContent, handleUpdatePost, handleDeletePost } = usePostEdit(id, userId, accessToken);
21+
const { title, setTitle, content, setContent, handleUpdatePost, handleDeletePost } = usePostEdit(id, userId);
2422

2523
function handleImageUpload(this: { quill: Quill }) {
2624
const editor = this.quill;
@@ -40,7 +38,7 @@ export default function EditPostContent({ params, userId, accessToken }: EditPos
4038
const response = await axiosInstance.post(API_URLS.UPLOADS, formData, {
4139
headers: {
4240
"Content-Type": "multipart/form-data",
43-
Authorization: `Bearer ${Cookies.get("accessToken")}`,
41+
requiresAuth: true
4442
},
4543
});
4644

apps/next-client/src/hooks/queries/usePostEdit.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ export function usePostEditData(id: string, userId: string | undefined) {
3030
}
3131

3232
// 게시글 업데이트 기능
33-
export function useUpdatePost(id: string, accessToken: string) {
33+
export function useUpdatePost(id: string) {
3434
const router = useRouter();
3535
const queryClient = useQueryClient();
3636

@@ -44,7 +44,7 @@ export function useUpdatePost(id: string, accessToken: string) {
4444
return axiosInstance.put(
4545
`${API_URLS.POSTS}/${id}`,
4646
{ title, content },
47-
{ headers: { Authorization: `Bearer ${accessToken}` } }
47+
{ headers: { requiresAuth: true } }
4848
);
4949
},
5050
onSuccess: () => {
@@ -60,7 +60,7 @@ export function useUpdatePost(id: string, accessToken: string) {
6060
}
6161

6262
// 게시글 삭제 기능
63-
export function useDeletePost(id: string, accessToken: string) {
63+
export function useDeletePost(id: string) {
6464
const router = useRouter();
6565
const queryClient = useQueryClient();
6666

@@ -71,7 +71,7 @@ export function useDeletePost(id: string, accessToken: string) {
7171
}
7272

7373
return axiosInstance.delete(`${API_URLS.POSTS}/${id}`, {
74-
headers: { Authorization: `Bearer ${accessToken}` }
74+
headers: { requiresAuth: true }
7575
});
7676
},
7777
onSuccess: () => {
@@ -86,13 +86,13 @@ export function useDeletePost(id: string, accessToken: string) {
8686
});
8787
}
8888

89-
export const usePostEdit = (id: string, userId: string | undefined, accessToken: string) => {
89+
export const usePostEdit = (id: string, userId: string | undefined) => {
9090
const [title, setTitle] = useState('');
9191
const [content, setContent] = useState('');
9292

9393
const { data } = usePostEditData(id, userId);
94-
const updatePostMutation = useUpdatePost(id, accessToken);
95-
const deletePostMutation = useDeletePost(id, accessToken);
94+
const updatePostMutation = useUpdatePost(id);
95+
const deletePostMutation = useDeletePost(id);
9696

9797
useEffect(() => {
9898
if (data) {

0 commit comments

Comments
 (0)