This commit is contained in:
parent
b0983137ee
commit
f5b9084468
|
|
@ -53,15 +53,23 @@ export default async function Login({
|
||||||
|
|
||||||
if (typeof window !== "undefined") {
|
if (typeof window !== "undefined") {
|
||||||
// 客户端环境下,使用 window.location.host
|
// 客户端环境下,使用 window.location.host
|
||||||
|
console.log("客户端环境:使用 window.location.host 获取 host");
|
||||||
hosturl = `http://${window.location.host}`;
|
hosturl = `http://${window.location.host}`;
|
||||||
} else {
|
} else {
|
||||||
// 服务器端环境下,使用 next/headers 获取 host
|
// 服务器端环境下,使用 next/headers 获取 host
|
||||||
const hostHeader = headers().get('host');
|
const hostHeader = headers().get('host');
|
||||||
hosturl = hostHeader ? `http://${hostHeader}` : process.env.SUPABASE_URL;
|
if (hostHeader) {
|
||||||
|
console.log("服务器端环境:使用 headers().get('host') 获取 host", hostHeader);
|
||||||
|
hosturl = `http://${hostHeader}`;
|
||||||
|
} else {
|
||||||
|
console.log("服务器端环境:没有获取到 host,从环境变量中获取 SUPABASE_URL", process.env.SUPABASE_URL);
|
||||||
|
hosturl = process.env.SUPABASE_URL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
console.log("最终的 hosturl 值:", hosturl);
|
||||||
if (hosturl) {
|
if (hosturl) {
|
||||||
await fetch(`${hosturl}/api/clearCookies`, {
|
await fetch(`${hosturl}/api/clearcookies`, {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue