From f5b9084468734d54c83e4e567962a696c60d8e8e Mon Sep 17 00:00:00 2001 From: hailin Date: Wed, 21 May 2025 17:05:31 +0800 Subject: [PATCH] . --- chatdesk-ui/app/[locale]/login/page.tsx | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/chatdesk-ui/app/[locale]/login/page.tsx b/chatdesk-ui/app/[locale]/login/page.tsx index 03bd4d4..647f0f7 100644 --- a/chatdesk-ui/app/[locale]/login/page.tsx +++ b/chatdesk-ui/app/[locale]/login/page.tsx @@ -53,15 +53,23 @@ export default async function Login({ if (typeof window !== "undefined") { // 客户端环境下,使用 window.location.host + console.log("客户端环境:使用 window.location.host 获取 host"); hosturl = `http://${window.location.host}`; } else { // 服务器端环境下,使用 next/headers 获取 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) { - await fetch(`${hosturl}/api/clearCookies`, { + await fetch(`${hosturl}/api/clearcookies`, { method: "POST", }); } else {