mirror of
https://github.com/bytedance/deer-flow.git
synced 2026-05-24 08:55:59 +00:00
fix(frontend): route agent checks to gateway (#1572)
* fix(frontend): route agent checks to gateway * fix(frontend): proxy langgraph requests locally * fix(frontend): keep zh-CN text readable * fix(frontend): add exact local api rewrites * fix(frontend): support docker-safe internal rewrites * Update frontend/src/core/agents/api.ts Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --------- Co-authored-by: Willem Jiang <willem.jiang@gmail.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
@@ -4,9 +4,51 @@
|
||||
*/
|
||||
import "./src/env.js";
|
||||
|
||||
function getInternalServiceURL(envKey, fallbackURL) {
|
||||
const configured = process.env[envKey]?.trim();
|
||||
return configured && configured.length > 0
|
||||
? configured.replace(/\/+$/, "")
|
||||
: fallbackURL;
|
||||
}
|
||||
|
||||
/** @type {import("next").NextConfig} */
|
||||
const config = {
|
||||
devIndicators: false,
|
||||
async rewrites() {
|
||||
const rewrites = [];
|
||||
const langgraphURL = getInternalServiceURL(
|
||||
"DEER_FLOW_INTERNAL_LANGGRAPH_BASE_URL",
|
||||
"http://127.0.0.1:2024",
|
||||
);
|
||||
const gatewayURL = getInternalServiceURL(
|
||||
"DEER_FLOW_INTERNAL_GATEWAY_BASE_URL",
|
||||
"http://127.0.0.1:8001",
|
||||
);
|
||||
|
||||
if (!process.env.NEXT_PUBLIC_LANGGRAPH_BASE_URL) {
|
||||
rewrites.push({
|
||||
source: "/api/langgraph",
|
||||
destination: langgraphURL,
|
||||
});
|
||||
rewrites.push({
|
||||
source: "/api/langgraph/:path*",
|
||||
destination: `${langgraphURL}/:path*`,
|
||||
});
|
||||
}
|
||||
|
||||
if (!process.env.NEXT_PUBLIC_BACKEND_BASE_URL) {
|
||||
rewrites.push({
|
||||
source: "/api/agents",
|
||||
destination: `${gatewayURL}/api/agents`,
|
||||
});
|
||||
rewrites.push({
|
||||
source: "/api/agents/:path*",
|
||||
destination: `${gatewayURL}/api/agents/:path*`,
|
||||
});
|
||||
}
|
||||
|
||||
return rewrites;
|
||||
},
|
||||
};
|
||||
|
||||
export default config;
|
||||
|
||||
Reference in New Issue
Block a user