Files
2026-03-23 02:18:43 -05:00

29 lines
1.0 KiB
TypeScript
Raw Permalink 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.
/**
* 域名配置(腾讯云生产)
* - 前端: https://salon.hackrobot.cn
* - salonapi: https://salonapi.hackrobot.cnjoin、支付等
*/
const isDev = process.env.NODE_ENV === "development";
/** 生产环境 salonapi 主机(非 api.根域名 模式) */
const DEFAULT_PROD_PAYMENT_API_HOST = "salonapi.hackrobot.cn";
/** 兼容旧逻辑:未单独设 PAYMENT_API_URL 时用于文档/兜底 */
export const ROOT_DOMAIN =
process.env.ROOT_DOMAIN || process.env.NEXT_PUBLIC_ROOT_DOMAIN || "hackrobot.cn";
/** salonapi 默认地址。开发连本地 8007生产连 salonapi.hackrobot.cn */
export const DEFAULT_PAYMENT_API_URL = isDev
? "http://127.0.0.1:8007"
: `https://${DEFAULT_PROD_PAYMENT_API_HOST}`;
/** 解析 salonapi 公网地址 */
export function resolvePaymentApiUrl(): string {
const url = process.env.PAYMENT_API_URL || DEFAULT_PAYMENT_API_URL;
if (!isDev && /^(https?:\/\/)?(127\.0\.0\.1|localhost)(:\d+)?(\/|$)/i.test(url)) {
return `https://${DEFAULT_PROD_PAYMENT_API_HOST}`;
}
return url.replace(/\/$/, "");
}