;s;
This commit is contained in:
@@ -20,6 +20,15 @@ export const ROOT_DOMAIN =
|
||||
export const AUTH_COOKIE_DOMAIN =
|
||||
process.env.AUTH_COOKIE_DOMAIN || `.${ROOT_DOMAIN}`;
|
||||
|
||||
/** 根据请求 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 AUTH_COOKIE_DOMAIN;
|
||||
}
|
||||
|
||||
/** 支付 API 默认地址 */
|
||||
export const DEFAULT_PAYMENT_API_URL = isDev
|
||||
? "http://127.0.0.1:8700"
|
||||
|
||||
Reference in New Issue
Block a user