mirror of
https://github.com/bytedance/deer-flow.git
synced 2026-04-25 11:18:22 +00:00
Fixes #2203 When NEXT_PUBLIC_BACKEND_BASE_URL is not set, the frontend uses Next.js rewrites to proxy API calls to the gateway. Skills API routes were missing from the rewrite config, causing /api/skills to return the SPA HTML instead of JSON, which produced 'Unexpected token <' errors in the skill settings page. Co-authored-by: JasonOA888 <JasonOA888@users.noreply.github.com>
70 lines
1.7 KiB
JavaScript
70 lines
1.7 KiB
JavaScript
/**
|
|
* Run `build` or `dev` with `SKIP_ENV_VALIDATION` to skip env validation. This is especially useful
|
|
* for Docker builds.
|
|
*/
|
|
import "./src/env.js";
|
|
|
|
function getInternalServiceURL(envKey, fallbackURL) {
|
|
const configured = process.env[envKey]?.trim();
|
|
return configured && configured.length > 0
|
|
? configured.replace(/\/+$/, "")
|
|
: fallbackURL;
|
|
}
|
|
import nextra from "nextra";
|
|
|
|
const withNextra = nextra({});
|
|
|
|
/** @type {import("next").NextConfig} */
|
|
const config = {
|
|
i18n: {
|
|
locales: ["en", "zh"],
|
|
defaultLocale: "en",
|
|
},
|
|
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*`,
|
|
});
|
|
rewrites.push({
|
|
source: "/api/skills",
|
|
destination: `${gatewayURL}/api/skills`,
|
|
});
|
|
rewrites.push({
|
|
source: "/api/skills/:path*",
|
|
destination: `${gatewayURL}/api/skills/:path*`,
|
|
});
|
|
}
|
|
|
|
return rewrites;
|
|
},
|
|
};
|
|
|
|
export default withNextra(config);
|