19 lines
453 B
TypeScript
19 lines
453 B
TypeScript
import { getRuntimeEnv } from "@/lib/ipconfig";
|
|
|
|
export async function getBaseUrl() {
|
|
let ip = await getRuntimeEnv("SUPABASE_URL");
|
|
if (!ip) throw new Error("SUPABASE_URL 获取失败,无法构建 baseUrl");
|
|
|
|
let protocol = "http";
|
|
if (
|
|
typeof window !== "undefined" &&
|
|
window.location &&
|
|
window.location.protocol === "https:"
|
|
) {
|
|
protocol = "https";
|
|
ip = window.location.hostname;
|
|
}
|
|
|
|
return `${protocol}://${ip}`;
|
|
}
|