This repository has no description
1const appUrl = process.env.NEXT_PUBLIC_APP_URL || 'http://127.0.0.1:4000';
2
3export class ClientCookieAuthService {
4 // Note: With HttpOnly cookies, we cannot read tokens from document.cookie
5 // The browser automatically sends cookies with requests using credentials: 'include'
6 // All auth logic (checking status, refreshing tokens) is handled by /api/auth/me endpoint
7
8 // Clear cookies via API (logout)
9 static async clearTokens(): Promise<void> {
10 try {
11 const response = await fetch(`${appUrl}/api/auth/logout`, {
12 method: 'POST',
13 credentials: 'include',
14 });
15
16 if (!response.ok) {
17 console.warn(
18 'Logout API call failed, but continuing with client-side logout',
19 );
20 }
21 } catch (error) {
22 console.error('Logout API call failed:', error);
23 // Don't throw - we still want to clear the UI state
24 }
25 }
26}