fix(WEB): FCM 토큰 등록을 위한 is_authenticated 쿠키 추가

- HttpOnly 쿠키(access_token)는 JavaScript에서 읽을 수 없어 FCM 초기화 실패
- non-HttpOnly is_authenticated 쿠키 추가로 클라이언트에서 인증 상태 확인 가능
- login/logout/refresh/proxy 라우트에서 쿠키 설정/삭제 처리
- hasAuthToken()이 is_authenticated 쿠키 확인하도록 변경
This commit is contained in:
2026-01-06 21:47:57 +09:00
parent 50a01e1e47
commit df51cf6852
5 changed files with 63 additions and 11 deletions

View File

@@ -32,11 +32,16 @@ export const getMultipartHeaders = (): HeadersInit => {
};
/**
* 토큰 존재 여부 확인
* 인증 상태 확인
*
* ⚠️ 중요: access_token은 HttpOnly 쿠키로 JavaScript에서 읽을 수 없음
* - is_authenticated 쿠키는 non-HttpOnly로 JavaScript에서 접근 가능
* - 로그인/토큰갱신 시 함께 설정되어 인증 상태를 나타냄
* - FCM 토큰 등록 등 클라이언트에서 인증 상태 확인이 필요한 경우 사용
*/
export const hasAuthToken = (): boolean => {
if (typeof window === 'undefined') return false;
// ✅ access_token 쿠키 존재 여부 확인
const token = document.cookie.split('; ').find(row => row.startsWith('access_token='))?.split('=')[1];
return !!token;
// ✅ is_authenticated 쿠키로 인증 상태 확인 (non-HttpOnly)
const isAuth = document.cookie.split('; ').find(row => row.startsWith('is_authenticated='))?.split('=')[1];
return isAuth === 'true';
};