feat: switch to a central singleton handler

This also adds support for Headscale TLS installations
This commit is contained in:
Aarnav Tale 2025-03-17 22:21:16 -04:00
parent 43e06987ad
commit 6108de52e7
No known key found for this signature in database
35 changed files with 339 additions and 399 deletions

View file

@ -1,4 +1,5 @@
import { Session, createCookieSessionStorage } from 'react-router';
import { hp_getConfig } from '~server/context/global';
export type SessionData = {
hsApiKey: string;
@ -21,6 +22,8 @@ type SessionFlashData = {
};
// TODO: Domain config in cookies
// TODO: Move this to the singleton system
const context = hp_getConfig();
const sessionStorage = createCookieSessionStorage<
SessionData,
SessionFlashData
@ -31,8 +34,8 @@ const sessionStorage = createCookieSessionStorage<
maxAge: 60 * 60 * 24, // 24 hours
path: '/',
sameSite: 'lax',
secrets: [__cookie_context.cookie_secret],
secure: __cookie_context.cookie_secure,
secrets: [context.server.cookie_secret],
secure: context.server.cookie_secure,
},
});