Skip to content

Commit e79ab2b

Browse files
authored
Merge pull request #278 from manNomi/fix/qa-bug
Fix : 미들웨어와 queryKey 수정하다
2 parents d97ffdb + 8c03089 commit e79ab2b

5 files changed

Lines changed: 10 additions & 11 deletions

File tree

src/api/auth/client/usePostLogout.ts

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import { useRouter } from "next/navigation";
2-
31
import { AxiosResponse } from "axios";
42

53
import { axiosInstance } from "@/utils/axiosInstance";
@@ -11,20 +9,17 @@ import { useMutation, useQueryClient } from "@tanstack/react-query";
119
export const postLogout = (): Promise<AxiosResponse<null>> => axiosInstance.post("/auth/sign-out");
1210

1311
const usePostLogout = () => {
14-
const router = useRouter();
1512
const { clearAccessToken } = useAuthStore();
1613
const queryClient = useQueryClient(); // 쿼리 캐시 관리를 위해 클라이언트 인스턴스를 가져옵니다.
1714

1815
return useMutation({
1916
mutationFn: postLogout,
20-
onMutate: () => {
21-
// 낙관적 업데이트: 로그아웃 요청이 시작되면 바로 로그인 상태를 false로 변경합니다.
22-
router.replace("/");
23-
},
2417
onSuccess: () => {
2518
clearAccessToken();
2619
removeAccessTokenToLS();
2720
queryClient.clear();
21+
// 로그아웃 후 홈으로 리다이렉트
22+
window.location.href = "/";
2823
},
2924
onError: (error) => {
3025
// 네트워크 오류 등으로 로그아웃 요청이 실패했을 경우를 대비한 처리입니다.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export enum QueryKeys {
2+
postList = "postList1",
3+
}

src/api/boards/clients/useGetMyInfo copy.ts

Whitespace-only changes.

src/api/boards/clients/useGetPostList.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { AxiosResponse } from "axios";
22

33
import { axiosInstance } from "@/utils/axiosInstance";
44

5-
import { QueryKeys } from "../../my/client/queryKey";
5+
import { QueryKeys } from "./QueryKeys";
66

77
import { ListPost } from "@/types/community";
88

@@ -22,7 +22,7 @@ const getPostList = (boardCode: string, category: string | null = null): Promise
2222

2323
const useGetPostList = ({ boardCode, category = null }: UseGetPostListProps) => {
2424
return useQuery({
25-
queryKey: [QueryKeys.myInfo],
25+
queryKey: [QueryKeys.postList],
2626
queryFn: () => getPostList(boardCode, category),
2727
// staleTime을 무한으로 설정하여 불필요한 자동 refetch를 방지합니다.
2828
staleTime: Infinity,

src/middleware.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ export function middleware(request: NextRequest) {
3434

3535
return NextResponse.next();
3636
}
37-
3837
export const config = {
39-
matcher: ["/((?!_next|favicon.ico).*)"],
38+
matcher: [
39+
"/((?!api|_next/static|_next/image|static/chunks|images|assets|favicon.ico|sw.js|viewer|fonts|.*\\.splat).*)",
40+
],
4041
};

0 commit comments

Comments
 (0)