mirror of
https://gitee.com/wanwujie/deer-flow
synced 2026-04-19 12:24:46 +08:00
feat: support NEXT_PUBLIC_LANGGRAPH_BASE_URL
This commit is contained in:
@@ -2,12 +2,12 @@
|
|||||||
|
|
||||||
import { Client as LangGraphClient } from "@langchain/langgraph-sdk/client";
|
import { Client as LangGraphClient } from "@langchain/langgraph-sdk/client";
|
||||||
|
|
||||||
import { getBackendBaseURL } from "../config";
|
import { getLangGraphBaseURL } from "../config";
|
||||||
|
|
||||||
let _singleton: LangGraphClient | null = null;
|
let _singleton: LangGraphClient | null = null;
|
||||||
export function getAPIClient(): LangGraphClient {
|
export function getAPIClient(): LangGraphClient {
|
||||||
_singleton ??= new LangGraphClient({
|
_singleton ??= new LangGraphClient({
|
||||||
apiUrl: getBackendBaseURL(),
|
apiUrl: getLangGraphBaseURL(),
|
||||||
});
|
});
|
||||||
return _singleton;
|
return _singleton;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,3 +7,11 @@ export function getBackendBaseURL() {
|
|||||||
return "http://localhost:8000";
|
return "http://localhost:8000";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function getLangGraphBaseURL() {
|
||||||
|
if (env.NEXT_PUBLIC_LANGGRAPH_BASE_URL) {
|
||||||
|
return env.NEXT_PUBLIC_LANGGRAPH_BASE_URL;
|
||||||
|
} else {
|
||||||
|
return getBackendBaseURL();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ export const env = createEnv({
|
|||||||
*/
|
*/
|
||||||
client: {
|
client: {
|
||||||
NEXT_PUBLIC_BACKEND_BASE_URL: z.string().optional(),
|
NEXT_PUBLIC_BACKEND_BASE_URL: z.string().optional(),
|
||||||
|
NEXT_PUBLIC_LANGGRAPH_BASE_URL: z.string().optional(),
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -39,6 +40,7 @@ export const env = createEnv({
|
|||||||
NODE_ENV: process.env.NODE_ENV,
|
NODE_ENV: process.env.NODE_ENV,
|
||||||
|
|
||||||
NEXT_PUBLIC_BACKEND_BASE_URL: process.env.NEXT_PUBLIC_BACKEND_BASE_URL,
|
NEXT_PUBLIC_BACKEND_BASE_URL: process.env.NEXT_PUBLIC_BACKEND_BASE_URL,
|
||||||
|
NEXT_PUBLIC_LANGGRAPH_BASE_URL: process.env.NEXT_PUBLIC_LANGGRAPH_BASE_URL,
|
||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
* Run `build` or `dev` with `SKIP_ENV_VALIDATION` to skip env validation. This is especially
|
* Run `build` or `dev` with `SKIP_ENV_VALIDATION` to skip env validation. This is especially
|
||||||
|
|||||||
Reference in New Issue
Block a user