Files
copilotkit__copilotkit/showcase/shell-dashboard/next.config.ts
Jordan Ritter b19c27f045 fix(showcase/shell-dashboard): resolve OPS_BASE_URL at runtime via /api/ops route handler
The /api/ops/* proxy was a next.config.ts rewrite, which Next.js evaluates at
`next build` and freezes into the prebuilt Docker image. The shared CI build
bakes a placeholder OPS_BASE_URL (http://ops.invalid) to satisfy a
throw-if-unset guard, so every deploy of the single :latest image proxied to a
dead host regardless of its runtime env — /api/ops/* returned 500
(ENOTFOUND ops.invalid), the Feature Matrix health overlay got no probe data,
and every cell downgraded to amber (zero green) despite green backend data.
The same freeze also baked the production harness URL into the shared image,
so even a correct rebuild would point staging at the prod harness.

Replace the build-time rewrite with a Route Handler at
src/app/api/ops/[...path]/route.ts that reads process.env.OPS_BASE_URL at
REQUEST time (force-dynamic, never statically cached) and proxies
/api/ops/<path> -> ${OPS_BASE_URL}/api/<path>, forwarding method, query
string, headers, and body. A missing OPS_BASE_URL now returns a clear 503
instead of a build throw. The build no longer depends on OPS_BASE_URL.

This fixes both traps with one image: each environment resolves its own
runtime OPS_BASE_URL from the same artifact, no rebuild. Requires the
dashboard image to rebuild + redeploy. Harness path is now /api/probes.
2026-06-01 07:46:27 -07:00

28 lines
1.3 KiB
TypeScript

import type { NextConfig } from "next";
/**
* Next.js config for the dashboard shell.
*
* The Status tab calls the showcase-harness HTTP API at the relative path
* `/api/ops/*`. That path is served at REQUEST time by the Route Handler at
* `src/app/api/ops/[...path]/route.ts`, which reads `OPS_BASE_URL` from the
* live process env and proxies to `${OPS_BASE_URL}/api/*`.
*
* It used to be a `rewrites()` entry, but `next build` freezes `rewrites()`
* into the prebuilt Docker image — so the placeholder `OPS_BASE_URL` baked at
* build time was frozen too, and every deploy proxied to a dead host
* regardless of its runtime env. Moving the proxy into a Route Handler makes
* `OPS_BASE_URL` runtime-resolved: the single shared image serves each
* environment's own harness URL with no rebuild. As a result this config no
* longer reads `OPS_BASE_URL` and `next build` no longer depends on it.
*
* Going same-origin (vs. a direct cross-origin browser call) sidesteps two
* production blockers that remain relevant to the Route Handler too:
* 1. showcase-harness has no CORS allowlist for cross-origin browser calls.
* 2. The ops base URL stays out of the client bundle (no `NEXT_PUBLIC_*`
* exposure).
*/
const nextConfig: NextConfig = {};
export default nextConfig;