import { getRuntimeEnv } from "@/lib/ipconfig"; export async function getBaseUrl() { let ip = await getRuntimeEnv("SUPABASE_URL"); if (!ip) throw new Error("SUPABASE_URL 获取失败"); if (typeof window === "undefined") { // ✅ 只在服务端导入(避免构建失败) const { getServerBaseUrl } = await import("./getServerBaseUrl"); return getServerBaseUrl(ip); } // ✅ 客户端逻辑 let protocol = window.location.protocol.replace(":", ""); let hostname = window.location.hostname; let port = protocol === "https" ? 443 : 80; return `${protocol}://${hostname}:${port}`; }