Files
gitlab-instance-0a899031_salon/config/domain.config.ts
2026-03-16 09:32:35 -05:00

26 lines
880 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.
/**
* 域名配置
* - salon 前端线上: nomadyt.com
* - salonapi 后端线上: api.nomadyt.comjoin、支付等
*/
const isDev = process.env.NODE_ENV === "development";
/** 根域名。前端 nomadyt.com后端 api.nomadyt.com */
export const ROOT_DOMAIN =
process.env.ROOT_DOMAIN || process.env.NEXT_PUBLIC_ROOT_DOMAIN || "nomadyt.com";
/** salonapi 默认地址。开发连本地 8007生产连 api.nomadyt.com */
export const DEFAULT_PAYMENT_API_URL = isDev
? "http://127.0.0.1:8007"
: `https://api.${ROOT_DOMAIN}`;
/** 解析 salonapi 地址api.nomadyt.com */
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://api.${ROOT_DOMAIN}`;
}
return url.replace(/\/$/, "");
}