mirror of
https://gitee.com/wanwujie/deer-flow
synced 2026-04-02 22:02:13 +08:00
42 lines
1011 B
TypeScript
42 lines
1011 B
TypeScript
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,
|
|
getBaseOrigin(),
|
|
).toString();
|
|
} else {
|
|
return "";
|
|
}
|
|
}
|
|
|
|
export function getLangGraphBaseURL(isMock?: boolean) {
|
|
if (env.NEXT_PUBLIC_LANGGRAPH_BASE_URL) {
|
|
return new URL(
|
|
env.NEXT_PUBLIC_LANGGRAPH_BASE_URL,
|
|
getBaseOrigin(),
|
|
).toString();
|
|
} else if (isMock) {
|
|
if (typeof window !== "undefined") {
|
|
return `${window.location.origin}/mock/api`;
|
|
}
|
|
return "http://localhost:3000/mock/api";
|
|
} else {
|
|
// LangGraph SDK requires a full URL, construct it from current origin
|
|
if (typeof window !== "undefined") {
|
|
return `${window.location.origin}/api/langgraph`;
|
|
}
|
|
// Fallback for SSR
|
|
return "http://localhost:2026/api/langgraph";
|
|
}
|
|
}
|