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:
@@ -170,12 +170,23 @@ export async function POST(request: NextRequest) {
|
||||
'Max-Age=604800', // TODO: 테스트용 10초, 원래 604800 (7 days)
|
||||
].join('; ');
|
||||
|
||||
// ✅ FCM 등에서 인증 상태 확인용 (non-HttpOnly - JavaScript 접근 가능)
|
||||
const isAuthenticatedCookie = [
|
||||
'is_authenticated=true',
|
||||
// HttpOnly 제외 - JavaScript에서 접근 가능해야 함
|
||||
...(isProduction ? ['Secure'] : []),
|
||||
'SameSite=Lax',
|
||||
'Path=/',
|
||||
`Max-Age=${data.expires_in || 7200}`,
|
||||
].join('; ');
|
||||
|
||||
console.log('✅ Login successful - Access & Refresh tokens stored in HttpOnly cookies');
|
||||
|
||||
const response = NextResponse.json(responseData, { status: 200 });
|
||||
|
||||
response.headers.append('Set-Cookie', accessTokenCookie);
|
||||
response.headers.append('Set-Cookie', refreshTokenCookie);
|
||||
response.headers.append('Set-Cookie', isAuthenticatedCookie);
|
||||
|
||||
return response;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user