This commit is contained in:
parent
53e2804240
commit
1734b7bd85
|
|
@ -61,7 +61,7 @@
|
||||||
|
|
||||||
|
|
||||||
import { getRuntimeEnv } from "../ipconfig";
|
import { getRuntimeEnv } from "../ipconfig";
|
||||||
import { headers } from "next/headers";
|
//import { headers } from "next/headers";
|
||||||
|
|
||||||
export async function getAxiosConfig() {
|
export async function getAxiosConfig() {
|
||||||
let ip = await getRuntimeEnv("SUPABASE_URL");
|
let ip = await getRuntimeEnv("SUPABASE_URL");
|
||||||
|
|
@ -79,8 +79,10 @@ export async function getAxiosConfig() {
|
||||||
ip = window.location.hostname;
|
ip = window.location.hostname;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// ✅ SSR 场景,自动读取 headers
|
// ✅ SSR 场景,延迟导入 headers
|
||||||
|
const { headers } = await import("next/headers");
|
||||||
const hdrs = headers();
|
const hdrs = headers();
|
||||||
|
|
||||||
const forwardedProto = hdrs.get("x-forwarded-proto");
|
const forwardedProto = hdrs.get("x-forwarded-proto");
|
||||||
const hostHeader = hdrs.get("host");
|
const hostHeader = hdrs.get("host");
|
||||||
|
|
||||||
|
|
@ -100,6 +102,7 @@ export async function getAxiosConfig() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
baseURL: `${protocol}://${ip}:${port}`,
|
baseURL: `${protocol}://${ip}:${port}`,
|
||||||
method: 'post',
|
method: 'post',
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue