fix: detect deployed Auth.js session cookie
Remote Build and Deploy / deploy (push) Successful in 44s

This commit is contained in:
Simo committed 2026-07-11 22:46:04 +02:00
1 parent 02bbcba240
commit cfa7998dd7
3 files changed
+24 -10

No files matched your search

+7 -2
View File
@@ -2,8 +2,13 @@ export interface ProxyToken {
rank?: unknown;
}
export function usesSecureAuthCookie(environment: string | undefined): boolean {
return environment === "production";
const AUTH_COOKIE_NAMES = ["__Secure-authjs.session-token", "authjs.session-token"] as const;
export function authSessionCookieName(cookieNames: readonly string[]): string | null {
for (const base of AUTH_COOKIE_NAMES) {
if (cookieNames.some((name) => name === base || name.startsWith(`${base}.`))) return base;
}
return null;
}
export function shouldRedirectAdminRequest(pathname: string, token: ProxyToken | null): boolean {