2026-01-19 11:23:40 +08:00
|
|
|
import { env } from "@/env";
|
|
|
|
|
|
|
|
|
|
export function getBackendBaseURL() {
|
2026-01-19 15:42:19 +08:00
|
|
|
if (env.NEXT_PUBLIC_BACKEND_BASE_URL) {
|
|
|
|
|
return env.NEXT_PUBLIC_BACKEND_BASE_URL;
|
|
|
|
|
} else {
|
2026-01-22 11:57:47 +08:00
|
|
|
return "";
|
2026-01-19 15:42:19 +08:00
|
|
|
}
|
2026-01-19 11:23:40 +08:00
|
|
|
}
|
2026-01-19 21:51:40 +08:00
|
|
|
|
2026-03-03 21:32:01 +08:00
|
|
|
export function getLangGraphBaseURL(isMock?: boolean) {
|
2026-01-19 21:51:40 +08:00
|
|
|
if (env.NEXT_PUBLIC_LANGGRAPH_BASE_URL) {
|
|
|
|
|
return env.NEXT_PUBLIC_LANGGRAPH_BASE_URL;
|
2026-03-03 21:32:01 +08:00
|
|
|
} else if (isMock) {
|
|
|
|
|
if (typeof window !== "undefined") {
|
|
|
|
|
return `${window.location.origin}/mock/api`;
|
|
|
|
|
}
|
|
|
|
|
return "http://localhost:3000/mock/api";
|
2026-01-19 21:51:40 +08:00
|
|
|
} else {
|
2026-01-22 11:57:47 +08:00
|
|
|
// 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";
|
2026-01-19 21:51:40 +08:00
|
|
|
}
|
|
|
|
|
}
|