This commit is contained in:
eric
2026-03-12 19:54:58 -05:00
parent 14bbd3b306
commit f66859c032
31 changed files with 1132 additions and 312 deletions

View File

@@ -8,20 +8,9 @@ const isDev = process.env.NODE_ENV === "development";
export const ROOT_DOMAIN =
process.env.ROOT_DOMAIN || process.env.NEXT_PUBLIC_ROOT_DOMAIN || "hackrobot.cn";
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 默认地址(本地可用 PAYMENT_API_URL 覆盖) */
export const DEFAULT_PAYMENT_API_URL = isDev
? "http://127.0.0.1:8700"
? "http://127.0.0.1:8007"
: `https://api.${ROOT_DOMAIN}`;
export const DEFAULT_POCKETBASE_URL = `https://pocketbase.${ROOT_DOMAIN}`;