From 2887cb5c35508fbe7dc501dbfd235b01bc61b351 Mon Sep 17 00:00:00 2001 From: swcho Date: Wed, 15 Oct 2025 18:10:35 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20=EC=BF=A0=ED=82=A4=20=EC=84=A4=EC=A0=95?= =?UTF-8?q?=EC=97=90=20=EB=8F=84=EB=A9=94=EC=9D=B8=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../sn/src/entities/auth/lib/token-manager.ts | 20 ++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/apps/sn/src/entities/auth/lib/token-manager.ts b/apps/sn/src/entities/auth/lib/token-manager.ts index 6387f06e5..0f6b34023 100644 --- a/apps/sn/src/entities/auth/lib/token-manager.ts +++ b/apps/sn/src/entities/auth/lib/token-manager.ts @@ -5,7 +5,7 @@ export class TokenManager { private static instance: TokenManager; private refreshTimer: NodeJS.Timeout | null = null; - private constructor() {} + private constructor() { } public static getInstance(): TokenManager { if (!TokenManager.instance) { @@ -19,12 +19,30 @@ export class TokenManager { } public setToken(key: string, value: string): void { + // 환경에 따른 도메인 설정 + const domain = this.getCookieDomain(); + setCookie(key, value, { secure: window.location.protocol === "https:", sameSite: "lax", + domain: domain, + path: "/", }); } + private getCookieDomain(): string | undefined { + const hostname = window.location.hostname; + + // 개발 환경에서는 localhost 도메인 사용 + if (hostname === "localhost" || hostname === "127.0.0.1") return undefined; // localhost에서는 도메인 설정하지 않음 + + // 운영 환경에서는 서브도메인을 포함한 최상위 도메인 사용 + if (hostname.includes("hasuon.or.kr")) return ".hasuon.or.kr"; // 모든 서브도메인에서 공유 + + // 기타 환경에서는 현재 호스트명 사용 + return hostname; + } + public removeToken(key: string): void { removeCookie(key); }