fix: refactor to use getBaseOrigin for URL construction in backend and LangGraph base URL functions (#1494)

This commit is contained in:
JeffJiang
2026-03-28 12:18:03 +08:00
committed by GitHub
parent 43ef3691a5
commit d22cab8614

View File

@@ -1,10 +1,18 @@
import { env } from "@/env";
function getBaseOrigin() {
if (typeof window !== "undefined") {
return window.location.origin;
}
return undefined;
}
export function getBackendBaseURL() {
if (env.NEXT_PUBLIC_BACKEND_BASE_URL) {
return new URL(
env.NEXT_PUBLIC_BACKEND_BASE_URL,
window.location.origin,
getBaseOrigin(),
).toString();
} else {
return "";
@@ -15,7 +23,7 @@ export function getLangGraphBaseURL(isMock?: boolean) {
if (env.NEXT_PUBLIC_LANGGRAPH_BASE_URL) {
return new URL(
env.NEXT_PUBLIC_LANGGRAPH_BASE_URL,
window.location.origin,
getBaseOrigin(),
).toString();
} else if (isMock) {
if (typeof window !== "undefined") {