Shared task board where people and AI coding agents work as teammates. Source-available, self-hostable.
Go
MUL-6610: fix(web): proxy /health to the backend in the runtime rewrite (#7467)
Felix021fbb4ec59da35
diff --git a/apps/web/config/runtime-urls.test.ts b/apps/web/config/runtime-urls.test.tsindex c23e70b0cb..462e3c8660 100644--- a/apps/web/config/runtime-urls.test.ts+++ b/apps/web/config/runtime-urls.test.ts@@ -276,6 +276,27 @@ describe("runtimeRewriteDestination", () => {).toBe("http://multica-docs:3000/docs/zh/agents");});+ it("maps the CLI health probe to the runtime API origin", () => {+ expect(+ runtimeRewriteDestination("/health", {+ REMOTE_API_URL: "http://backend:8080",+ }),+ ).toBe("http://backend:8080/health");+ expect(runtimeRewriteDestination("/health", {})).toBeUndefined();+ // Probe variants stay unproxied: /healthz is the k8s alias and /readyz+ // the deep check — both go to the backend directly in every topology.+ expect(+ runtimeRewriteDestination("/healthz", {+ REMOTE_API_URL: "http://backend:8080",+ }),+ ).toBeUndefined();+ expect(+ runtimeRewriteDestination("/readyz", {+ REMOTE_API_URL: "http://backend:8080",+ }),+ ).toBeUndefined();+ });+it("maps websocket paths to the runtime API origin", () => {expect(runtimeRewriteDestination("/ws", {diff --git a/apps/web/config/runtime-urls.ts b/apps/web/config/runtime-urls.tsindex 01cd624962..779cf9ba9e 100644--- a/apps/web/config/runtime-urls.ts+++ b/apps/web/config/runtime-urls.ts@@ -134,6 +134,14 @@ export function runtimeRewriteDestination(if (pathname === "/ws") {return appendPath(remoteApiUrl, "/ws");}+ // `multica setup self-host` probes `{server-url}/health` and treats any+ // non-200 as "Server not reachable". The backend serves it, but a+ // same-origin reverse proxy that forwards everything to the web image left+ // the probe 404ing at the Next.js router, so setup failed against a healthy+ // stack. Proxy the exact path like /ws.+ if (pathname === "/health") {+ return appendPath(remoteApiUrl, "/health");+ }if (isBackendAuthPath(pathname)) {return appendPath(remoteApiUrl, pathname);}diff --git a/apps/web/next.config.ts b/apps/web/next.config.tsindex 680b90e370..2437bd2d5a 100644--- a/apps/web/next.config.ts+++ b/apps/web/next.config.ts@@ -78,6 +78,10 @@ const nextConfig: NextConfig = {source: "/ws",destination: `${remoteApiUrl}/ws`,},+ {+ source: "/health",+ destination: `${remoteApiUrl}/health`,+ },{source: "/auth/:path*",destination: `${remoteApiUrl}/auth/:path*`,diff --git a/apps/web/proxy.test.ts b/apps/web/proxy.test.tsindex 20623421f8..e66d7981dd 100644--- a/apps/web/proxy.test.ts+++ b/apps/web/proxy.test.ts@@ -186,6 +186,21 @@ describe("proxy runtime upstream rewrites", () => {}});+ it("rewrites the CLI health probe to the runtime API origin", () => {+ const previous = process.env.REMOTE_API_URL;+ process.env.REMOTE_API_URL = "http://backend:8080";+ try {+ const res = proxy(makeRequest("/health"));++ expect(res.status).toBe(200);+ expect(res.headers.get("x-middleware-rewrite")).toBe(+ "http://backend:8080/health",+ );+ } finally {+ restoreEnv("REMOTE_API_URL", previous);+ }+ });+it("rewrites Plugin API requests to the runtime API origin", () => {const previous = process.env.REMOTE_API_URL;process.env.REMOTE_API_URL = "http://backend:8080";