🔒 Update COOKIE_OPTIONS to handle secure cookies based on environment (localhost vs production).

master
Alix JEUDI--LEMOINE 2 days ago
parent 53ce0dc21f
commit cf4aff473c

@ -11,12 +11,19 @@ export class CookiesService {
private readonly USERNAME_KEY = 'username'; private readonly USERNAME_KEY = 'username';
private readonly USER_ID = 'userId'; private readonly USER_ID = 'userId';
private readonly IS_ADMIN_KEY = 'isAdmin'; private readonly IS_ADMIN_KEY = 'isAdmin';
private readonly COOKIE_OPTIONS = {
path: '/', private get COOKIE_OPTIONS() {
domain: window.location.hostname, const isLocalhost = window.location.hostname === 'localhost' ||
secure: true, window.location.hostname === '127.0.0.1' ||
sameSite: 'Strict' as const, window.location.hostname.includes('localhost');
};
return {
path: '/',
domain: window.location.hostname,
secure: !isLocalhost,
sameSite: 'Strict' as const,
};
}
constructor( constructor(
private router: Router, private router: Router,

Loading…
Cancel
Save