Repository navigation
fix(den-web): redirect legacy /api/den callers to DEN_API_PUBLIC_URL, not the in-network DEN_API_BASE - #4793
Conversation
… not the in-network DEN_API_BASE Follow-up to #4768. den-web's legacy /api/den/* 307 (older desktop builds) resolved its Location from DEN_API_BASE first. In the documented Compose and Helm shapes DEN_API_BASE is the container-internal upstream the /api/auth/* proxy needs (http://den:8788), so browsers were redirected to a host they cannot reach. Prefer DEN_API_PUBLIC_URL, the browser-reachable origin that runtime-config already hands to new clients, then fall back to DEN_API_BASE, then api.<web host>, in both the route handler and its build-time mirror. The runtime side now also rejects non-http(s) schemes like the mirror did, so a scheme-less value no longer produces a "null" origin. The /api/auth/* proxy, readiness and the SSO probe keep reading DEN_API_BASE. Proof: extended den-web unit tests (route, origin, build-time parity) and a new PR-lane spec, evals/specs/den-web-public-api-redirect.test.ts, that boots the documented docker-compose.eval.yml as an isolated project with a locally built den-web image (OPENWORK_EVAL_DEN_WEB_IMAGE) and asserts from the host that the redirect lands on Den API health, the auth proxy still answers through the in-network upstream, runtime-config agrees with the redirect, and the same image without DEN_API_PUBLIC_URL keeps the DEN_API_BASE fallback.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Passed · 10/10 tests · 15/15 assertions · 5 images Commit |
Warden review summary — ClearNative findings: 1. Blocking policy matches before consolidation: 0. Full finding text remains in Warden's native checks and review threads. This comment retains only native IDs, severity, skill attribution, and safe locations. Analysis run Reported trigger coverage (not proof of complete repository or context coverage): diff-security-review (31848 ms), confidentiality-review (37753 ms), spec-provenance-review (79401 ms). Blockers
Advisories
Needs recheck
Observed review-thread metrics
Thread states are read-only collection snapshots. These metrics are neither lifetime totals nor exact resolution times, and this summary is not clearance authority. |
There was a problem hiding this comment.
Warden security clearance: clear. No blocking findings (security or desktop↔den sync) in this diff (bcb9470d954f078c96a948c6e8fa886c5706b077). Automated clearance satisfies the required-review gate only — a human still reviews and merges. Analysis run
Problem
Follow-up to #4768 ("Not fixed here" section). den-web's legacy
/api/den/*route (a 307 kept for older desktop builds) resolves itsLocationorigin fromDEN_API_BASEfirst, in both the route handler (app/(den)/_lib/den-api-origin.ts) and its build-time mirror (next-config-den-api-redirects.cjs). In the documented Compose stack (packaging/docker/docker-compose.eval.yml) and the Helm chart,DEN_API_BASEis the container-internal upstream the/api/auth/*proxy needs (http://den:8788,http://<release>-den-api:8788), so browsers were redirected to a host they cannot reach:/api/runtime-configalready hands new clientsDEN_API_PUBLIC_URL; the redirect disagreed with it.Change (den-web only)
den-api-origin.ts+next-config-den-api-redirects.cjs: browser-facing origin order is nowDEN_API_PUBLIC_URL→DEN_API_BASE→api.<web host>. The documented fallback is preserved: without a public URL nothing changes.localhost:18788) parsed as schemelocalhost:and yielded the string"null"as origin; the parity test surfaced it./api/auth/*proxy,/api/ready, the SSO probe and the dashboard layout keep readingDEN_API_BASE— untouched.ee/apps/den-web/README.md: documentsDEN_API_PUBLIC_URL.docker-compose.eval.yml(image pins are ci(release): pin the compose evaluation stack automatically after each release (gated remainder of #4732; scripts in #4905) #4732's; comments already describe the intended split).Proof
Unit (bun,
ee/apps/den-web) — extendedtests/den-api-origin.test.ts,tests/den-api-redirect-rules.test.ts(route/build-time parity across 3 new env shapes) andapp/api/_lib/den-api-redirect.test.mjs(through the realapp/api/den/[...path]/route.ts):pnpm --filter @openwork-ee/den-web test→ 234 pass / 1 fail:tests/cloud-super-admins-role-hierarchy.test.ts("Workflow Runs" label) — pre-existing, same single failure on clean base586c4100fwith this diff stashed.Runtime boundary (testkit PR lane, local, Docker Desktop) — new
evals/specs/den-web-public-api-redirect.test.ts+evals/worlds/den-compose-eval.ts. The world boots the documenteddocker-compose.eval.ymlas an isolated project (unique name/network/volume, free host ports, random secrets) with thewebservice swapped for a locally built den-web image (OPENWORK_EVAL_DEN_WEB_IMAGE,pull_policy: never) plus aweb-fallbackcontainer from the same image withDEN_API_PUBLIC_URLremoved. Five steps, each with the negative half:GET :web/api/den/health?probe=redirect→ 307,Locationorigin ==DEN_API_PUBLIC_URL, path/query preserved, origin !=http://den:8788{ok:true}on the public API origin/api/auth/ok200 (no redirect),/api/auth/get-session200,/api/readyupstreamok/api/runtime-configdenApiUrl== redirect originweb-fallback(noDEN_API_PUBLIC_URL): 307 →http://den:8788(documentedDEN_API_BASEfallback) and its/api/auth/okstill 200Negative control — same spec against the published
openwork-den-web:0.18.46@sha256:82affe9e…(the pin in the compose file): fails at step 1 withexpected 'http://den:8788' to be 'http://localhost:<port>', i.e. the spec observes exactly the reported defect. Compose project, volumes and network were removed after each run.The spec declares
needs: { commands: ["docker"], env: ["OPENWORK_EVAL_DEN_WEB_IMAGE"] }and skips loudly without a prebuilt image, so nightlyevals:prdoes not build images. Daytona lane not used: the proof drives local Docker; no placement dependency.Framework checks:
spec-boundary-ratchet,spec-channel-ratchet,lint:layers(39 known violations before and after),check:browser,tsc -p evals(381 pre-existing errors before and after) — none reference the new files.Warden (
pnpm warden:check, HEADbcb9470d9vs origin/dev586c4100f): diff-security-review, confidentiality-review, spec-provenance-review all completed — No findings, exit 0.Release dependency
The published den-web image cannot contain this fix; the Compose/Helm redirect is corrected only once a den-web image with this commit is released and #4732's pin automation moves
docker-compose.eval.ymlto it. Until then/api/runtime-config(new clients) is correct and only the legacy/api/den/*path is affected.