feat: 로그인 세션 만료시 CM 로그인 페이지로 리다이렉트 처리 (env 파일 도메인 재설정 필요)

This commit is contained in:
swcho
2025-09-23 11:35:18 +09:00
parent c54381ae71
commit 6c022cd1ec
2 changed files with 8 additions and 1 deletions
@@ -10,6 +10,7 @@ import { getCookie } from "@/shared/lib";
import { LoginApi } from "../api/login-service";
const CLAIM_NAME = process.env.NEXT_PUBLIC_CLAIM_NAME || "Authorization";
const LOGIN_PAGE_URL = process.env.NEXT_PUBLIC_DEV_CM_LOGIN_PAGE_URL; // 개발 환경 URL
const AuthWrapper = ({ children }: { children: React.ReactNode }) => {
const router = useRouter();
@@ -40,7 +41,10 @@ const AuthWrapper = ({ children }: { children: React.ReactNode }) => {
} catch (refreshError) {
console.error("Token refresh failed:", refreshError);
setUserInfo(null);
router.push("/");
// router.push("/"); // 개발시 홈으로 돌아가기
window.location.href = LOGIN_PAGE_URL; // 세션 만료 시 CM 로그인 페이지로 리다이렉트
// router.push는 같은 Next.js 앱 내에서만 작동하므로 다른 앱으로 이동할 때는 window.location.href 사용
}
}
})();