's'
This commit is contained in:
@@ -51,11 +51,20 @@ export function getApiUrlFromRequest(hostHeader: string | null): string {
|
||||
return isDev ? `http://${hostname}:${PAYJSAPI_PORT}` : "https://api.hackrobot.cn";
|
||||
}
|
||||
|
||||
export function getPaymentConfig(): PaymentConfig {
|
||||
const apiUrl =
|
||||
/** 生产环境若 PAYMENT_API_URL 指向 localhost,则忽略并使用 api 域名 */
|
||||
function resolvePaymentApiUrl(): string {
|
||||
const url =
|
||||
process.env.PAYMENT_API_URL ||
|
||||
process.env.NEXT_PUBLIC_API_URL ||
|
||||
(isDev ? `http://127.0.0.1:${PAYJSAPI_PORT}` : "https://api.hackrobot.cn");
|
||||
if (!isDev && /^(https?:\/\/)?(127\.0\.0\.1|localhost)(:\d+)?(\/|$)/i.test(url)) {
|
||||
return "https://api.hackrobot.cn";
|
||||
}
|
||||
return url;
|
||||
}
|
||||
|
||||
export function getPaymentConfig(): PaymentConfig {
|
||||
const apiUrl = resolvePaymentApiUrl();
|
||||
return {
|
||||
apiUrl,
|
||||
provider: (process.env.PAYMENT_PROVIDER as "zpay" | "xorpay") || "zpay",
|
||||
|
||||
Reference in New Issue
Block a user