fix, remove:
- 권한 체크를 최초 실행시만이 아니라 pathname 변경시로 변경. - hostname 로그 삭제
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
"use client";
|
||||
|
||||
import { useEffect } from "react";
|
||||
import { useRouter } from "next/navigation";
|
||||
import { useRouter, usePathname } from "next/navigation";
|
||||
import { client } from "@/shared/api";
|
||||
import type { IUserInfo } from "@/shared/store";
|
||||
import { useUserStore } from "@/shared/lib";
|
||||
@@ -14,6 +14,7 @@ const LOGIN_PAGE_URL = process.env.NEXT_PUBLIC_CM_LOGIN_PAGE_URL || "http://dev.
|
||||
|
||||
const AuthWrapper = ({ children }: { children: React.ReactNode }) => {
|
||||
const router = useRouter();
|
||||
const pathname = usePathname();
|
||||
const { userInfo, setUserInfo } = useUserStore((state) => state);
|
||||
|
||||
async function authCheck() {
|
||||
@@ -43,7 +44,6 @@ const AuthWrapper = ({ children }: { children: React.ReactNode }) => {
|
||||
setUserInfo(null);
|
||||
|
||||
const hostname = window.location.hostname;
|
||||
console.log("Current hostname:", hostname);
|
||||
|
||||
// 개발 환경에서는 localhost 도메인 사용
|
||||
if (hostname === "localhost" || hostname === "127.0.0.1" || hostname === "con.mind-one.co.kr")
|
||||
@@ -55,7 +55,7 @@ const AuthWrapper = ({ children }: { children: React.ReactNode }) => {
|
||||
}
|
||||
}
|
||||
})();
|
||||
}, []);
|
||||
}, [pathname]);
|
||||
|
||||
return <>{children}</>;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user