From 3b91df2b185678d469375cb8a69b5eeda36b8911 Mon Sep 17 00:00:00 2001 From: Jason Date: Sat, 18 Apr 2026 11:35:19 +0800 Subject: [PATCH] fix(frontend): add catch-all API rewrite for gateway routes (#2335) When NEXT_PUBLIC_BACKEND_BASE_URL is unset, the frontend proxies API requests to the gateway. Only /api/agents and /api/skills had rewrite rules, causing 404s for /api/models, /api/threads, /api/memory, /api/mcp, /api/suggestions, /api/runs, etc. Add a catch-all /api/:path* rewrite that proxies all remaining gateway API routes. The existing /api/langgraph rewrite takes priority because it is pushed to the array first (Next.js checks rewrites in order). Fixes #2327 Co-authored-by: JasonOA888 --- frontend/next.config.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/frontend/next.config.js b/frontend/next.config.js index 6d08b3cba..0f22635c2 100644 --- a/frontend/next.config.js +++ b/frontend/next.config.js @@ -60,6 +60,18 @@ const config = { source: "/api/skills/:path*", destination: `${gatewayURL}/api/skills/:path*`, }); + + // Catch-all for remaining gateway API routes (models, threads, memory, + // mcp, artifacts, uploads, suggestions, runs, etc.) that don't have + // their own NEXT_PUBLIC_* env var toggle. + // + // NOTE: this must come AFTER the /api/langgraph rewrite above so that + // LangGraph routes are matched first when NEXT_PUBLIC_LANGGRAPH_BASE_URL + // is unset. + rewrites.push({ + source: "/api/:path*", + destination: `${gatewayURL}/api/:path*`, + }); } return rewrites;