Files
gitlab-instance-0a899031_no…/app/lib/auth-cookie-domain.ts
2026-03-12 05:41:01 -05:00

12 lines
531 B
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/**
* 根据请求 host 返回 Cookie domain。
* localhost 时不设 domain生产环境用根域实现跨站 SSO。
*/
export function getAuthCookieDomain(request: { headers: { get: (name: string) => string | null } }): string | undefined {
const envDomain = process.env.AUTH_COOKIE_DOMAIN;
if (envDomain) return envDomain;
const host = request.headers.get("host") ?? "";
if (host.includes("localhost") || host.startsWith("127.0.0.1")) return undefined;
return process.env.AUTH_COOKIE_DOMAIN || ".hackrobot.cn";
}