fix(auth): isolate session cookies from other Auth.js apps on same host (#5996)

Prefix all Auth.js cookies (default "homarr") so they no longer collide
with other Auth.js apps on the same hostname.
This commit is contained in:
Thomas authored and GitHub committed 2026-06-19 21:24:15 +02:00
1 parent bf4396917e
commit e1a245ff2d
5 files changed
+30 -7

No files matched your search

+4 -2
View File
@@ -4,9 +4,11 @@ import { generateSecureRandomToken } from "@homarr/common/server";
import type { Database } from "@homarr/db";
import { getCurrentUserPermissionsAsync } from "./callbacks";
import { env } from "./env";
// Default of authjs
export const sessionTokenCookieName = "authjs.session-token";
// Prefixed (AUTH_COOKIE_PREFIX, default "homarr") to avoid cookie collisions
// with other Auth.js apps on the same host. See https://github.com/homarr-labs/homarr/issues/5773
export const sessionTokenCookieName = `${env.AUTH_COOKIE_PREFIX}.session-token`;
export const expireDateAfter = (seconds: number) => {
return new Date(Date.now() + seconds * 1000);