From 70a9a0b186d581edf461b2a28b2441281e6b137c Mon Sep 17 00:00:00 2001 From: swcho Date: Wed, 15 Oct 2025 13:43:13 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20=EA=B6=8C=ED=95=9C=20=EC=B2=B4=ED=81=AC?= =?UTF-8?q?=EB=A5=BC=20=EC=B5=9C=EC=B4=88=20=EC=8B=A4=ED=96=89=EC=8B=9C?= =?UTF-8?q?=EB=A7=8C=EC=9D=B4=20=EC=95=84=EB=8B=88=EB=9D=BC=20pathname=20?= =?UTF-8?q?=EB=B3=80=EA=B2=BD=EC=8B=9C=EB=A1=9C=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/wr/src/entities/auth/lib/auth-wrapper.tsx | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/apps/wr/src/entities/auth/lib/auth-wrapper.tsx b/apps/wr/src/entities/auth/lib/auth-wrapper.tsx index 6bb910132..cf9af93cc 100644 --- a/apps/wr/src/entities/auth/lib/auth-wrapper.tsx +++ b/apps/wr/src/entities/auth/lib/auth-wrapper.tsx @@ -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_DEV_CM_LOGIN_PAGE_URL || "http:// const AuthWrapper = ({ children }: { children: React.ReactNode }) => { const router = useRouter(); + const pathname = usePathname(); const { userInfo, setUserInfo } = useUserStore((state) => state); async function authCheck() { @@ -45,15 +46,17 @@ const AuthWrapper = ({ children }: { children: React.ReactNode }) => { const hostname = window.location.hostname; // 개발 환경에서는 localhost 도메인 사용 - if (hostname === "localhost" || hostname === "127.0.0.1") router.push("/"); // 개발시 홈으로 돌아가기 + if (hostname === "localhost" || hostname === "127.0.0.1" || hostname === "con.mind-one.co.kr") + router.push("/"); // 개발시 홈으로 돌아가기 // 운영 환경에서는 서브도메인을 포함한 최상위 도메인 사용 // router.push는 같은 Next.js 앱 내에서만 작동하므로 다른 앱으로 이동할 때는 window.location.href 사용 - if (hostname.includes("hasuon.or.kr")) window.location.href = LOGIN_PAGE_URL; // 세션 만료 시 CM 로그인 페이지로 리다이렉트 + if (hostname.includes("hasuon.or.kr")) + window.location.href = LOGIN_PAGE_URL; // 세션 만료 시 CM 로그인 페이지로 리다이렉트 } } })(); - }, []); + }, [pathname]); return <>{children}; };