s''
This commit is contained in:
@@ -36,10 +36,16 @@ export function getPocketBaseConfig(): PocketBaseConfig {
|
||||
if (serverSide && internal) {
|
||||
return { url: internal.replace(/\/$/, "") };
|
||||
}
|
||||
// 生产同机部署默认走本机 PocketBase,避免 DNS/公网抖动导致 fetch failed
|
||||
if (serverSide) {
|
||||
return {
|
||||
url: (process.env.POCKETBASE_URL || "http://127.0.0.1:8090").replace(/\/$/, ""),
|
||||
};
|
||||
}
|
||||
return {
|
||||
url:
|
||||
process.env.POCKETBASE_URL ||
|
||||
process.env.NEXT_PUBLIC_POCKETBASE_URL ||
|
||||
process.env.POCKETBASE_URL ||
|
||||
"https://pocketbase.hackrobot.cn",
|
||||
};
|
||||
}
|
||||
@@ -53,8 +59,11 @@ const PAYJSAPI_PORT = process.env.PAYJSAPI_PORT || "8007";
|
||||
export function getApiUrlFromRequest(hostHeader: string | null): string {
|
||||
const internal = process.env.PAYMENT_API_INTERNAL_URL?.trim();
|
||||
if (internal) return internal.replace(/\/$/, "");
|
||||
if (!hostHeader) return isDev ? `http://127.0.0.1:${PAYJSAPI_PORT}` : "https://api.hackrobot.cn";
|
||||
if (!hostHeader) return `http://127.0.0.1:${PAYJSAPI_PORT}`;
|
||||
const hostname = hostHeader.split(":")[0];
|
||||
if (!isDev && /^(vip\.hackrobot\.cn|www\.vip\.hackrobot\.cn)$/i.test(hostname)) {
|
||||
return `http://127.0.0.1:${PAYJSAPI_PORT}`;
|
||||
}
|
||||
return isDev ? `http://${hostname}:${PAYJSAPI_PORT}` : "https://api.hackrobot.cn";
|
||||
}
|
||||
|
||||
@@ -68,9 +77,9 @@ 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");
|
||||
`http://127.0.0.1:${PAYJSAPI_PORT}`;
|
||||
if (!isDev && /^(https?:\/\/)?(127\.0\.0\.1|localhost)(:\d+)?(\/|$)/i.test(url)) {
|
||||
return "https://api.hackrobot.cn";
|
||||
return `http://127.0.0.1:${PAYJSAPI_PORT}`;
|
||||
}
|
||||
return url;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user