Repository navigation
build(deploy): route only the server's own paths to it in the cloud - #2566
Conversation
With the API under /api/v1 (ADR 077), the server's function no longer needs vercel.json's catch-all. It gets the API, the few paths it answers at the root (the probes, /csp-report, the retention cron, the IdP callbacks, /console/runtime.json) and, until 1.0.0, the root paths of the API's resources in one rule; their names are fixed, because a client released before the prefix calls only operations it knows. Every other path is the website's, whose 404 now draws ADR 076's "Page not found". In production a fifth of the function's requests were 404s for paths it never serves: /robots.txt, scanners, the routing check's own not-found probe. They no longer start it. ADR 076 rejected routing by name because every new API path needed a rewrite of its own; the prefix ends that, so it is amended, and a launcher test resolves each of the server's paths through vercel.json. The deployment suite checks the server's paths, a junk path's 404 and the server's own not-found under the prefix. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
🔵 Needs a closer look
The change depends on Vercel's actual path-to-regexp routing behavior rather than the Go test's emulation, so preview deployment routing checks must be confirmed before merge to avoid production-only navigation breakage.
No open issues 🎉
What changed in this PR
This PR changes the hosted cloud's vercel.json routing so the Go server's serverless function receives only the paths it actually serves — the /api/* prefix, its own root paths (/livez, /readyz, /csp-report, /cron/events-retention, /console/runtime.json, the IdP callbacks) and, until 1.0.0, the deprecated root aliases of the API's 16 resources. Every other path now falls through the catch-all to the website, whose 404 page answers unmatched routes for browsers and programs alike. This stops scanner/typo traffic (97 /robots.txt, /.env, /.git/HEAD, etc.) from cold-starting the Go function, and it amends ADR 076 (which previously kept the catch-all on the server). It's the fifth PR in the /api/v1 prefix stack (#2356→#2359), building on the prefix that makes "route by name" viable: one /api/* rule plus a fixed list of pre-prefix resource names.
Changes:
- Rewrite
vercel.jsonrouting: server gets its own paths + a named-resource rule; the/(.*)catch-all now goes to the website. - Rework the website's
app/not-found.tsxto ADR 076 §4's 404 anatomy/copy ("Error 404" / "Page not found" / start-page + docs links). - Expand tests (
apps/cloud/launcher/main_test.goroute-resolution test with a richerroutePattern, and the console deploymentroutes.spec.ts) and update ADRs 076/077/081/084, the ADR index, cloud runbook/README, and website AGENTS.md.
I verified the resource list in vercel.json (auth_attempts…variables) exactly matches the 16 top-level resources in api/openapi/openapi-spec.yaml (probes /livez//readyz have their own rules), that all symbols referenced by the launcher test exist, that SiteHeader's current prop is optional and links.docs exists, that the website has no robots.txt (so the /robots.txt → 404 assertion holds), and that the 404 copy matches ADR 076 §4's copy table. The routePattern emulation faithfully models the forms used (literal, (.*), :param, :param(pattern), optional ?), and the bare-resource/optional-slash case is corroborated by the author's vercel dev run (bare /schemas, /flow_definitions reach the server). No changeset is required: @zitadel/website is private and changeset-ignored, and the rest is cloud config, tests, and docs.
| File | Description |
|---|---|
vercel.json |
Core change: adds server rules for its root paths + a named-resource rule; repoints the /(.*) catch-all to the website; moves /cloud/* up. |
apps/cloud/launcher/main_test.go |
New TestVercelJSONSendsTheServerOnlyItsOwnPaths and a rewritten routePattern/routeMatches supporting :param and :param(pattern)?. |
e2e/console/src-deployment/routes.spec.ts |
Splits routing assertions: server answers its root paths (with request ID), website answers junk/unmatched paths with its 404; API-prefix 404 still gets the server envelope. |
apps/website/app/not-found.tsx |
Rewrites the 404 page to ADR 076 §4 anatomy/copy; drops current="changelog", adds start-page + docs links. |
apps/website/AGENTS.md |
Updates routing note: website now takes every path no other service claims; lists the paths to avoid. |
apps/cloud/README.md |
Documents that the server gets only its own paths; everything else is the website's. |
docs/runbooks/cloud.md |
Updates the service routing table and routing notes to the new server/website split. |
docs/adrs/076-...md |
Amendment: cloud routes the server only its own paths; records the now-adopted "route by name" / "unmatched to website" decisions; adds the website's not-found.tsx. |
docs/adrs/077-...md |
§5 Cloud updated to the new routing and the alias's GA removal. |
docs/adrs/081-...md |
Notes the future /oauth/ namespace gets its own vercel.json rule when it ships. |
docs/adrs/084-...md |
Corrects "server's catch-all" → "website's catch-all" for /cloud/* ordering. |
docs/adrs/README.md |
Updates the ADR 076 index summary to the amended routing. |
apps/cli/tests/unit/lib/telemetry/config.test.ts |
Comment-only: "server's catch-all" → "catch-all" for the Mixpanel rule test. |
Review effort: Balanced
Brings in the stack's shared API prefix, the spec checks and #2359's console dev-proxy fix. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Brings in #2357's build edge for the cloud functions' tests. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…-catalog-mock Main serves the API under /api/v1 and routes only the server's own paths to it in the cloud (#2356 to #2359, #2566): - buildHTTPMux takes main's api.Servers and keeps this branch's cron triggers; a job no trigger runs leaves its path to the root alias. - vercel.json and the cloud runbook route /cron/usage to the server, as /cron/events-retention, or the usage cron would reach the website. - The functions' and the console's usage specs answer under /api/v1. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
#2558 now holds main, whose cloud routes every path no other service claims to the website (#2566). The page's own rewrite for /pricing goes with the explicit list, the website's AGENTS.md takes main's routing rule, and the deployment check opens /pricing beside main's 404 probe. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Context
vercel.json's catch-all. In production's last 1,000 requests to it (2026-10-30/31), 203 were 404s for paths it never serves: 97/robots.txt, 36 the routing check's own not-found probe, and scanners (/.env,/.git/HEAD,/actuator/env,/swagger.json, …). Each started the Go function.Summary
The server's function gets its own paths and nothing else; every other path is the website's.
vercel.json. The server keeps/api/*and/console/runtime.json, which had rules already, and gets rules for its other root paths:/livez,/readyz,/csp-report,/cron/events-retentionand the IdP callbacks (/idp/:slug/callback,/__nextgen/idp/:slug/callback). Until 1.0.0 one rule sends it the root paths of the API's sixteen resources (/users,/flow,/schemas, …), after/schemas/v1/*'s rule. The names are fixed: a client released before the prefix calls only operations it knows, so a resource added since needs no root rule. The catch-all/(.*)now goes to the website, and the website's own seven rules, which it covers, go./oauth/namespace gets a rule when it ships) and 084, the cloud runbook and README, and the website's AGENTS.md follow.apps/cloud/launcher: a new test resolves each of the server's paths throughvercel.json(taking them from the server's constants where it has one) and a set of others to the website, docs, console, schemas, cloud functions and the Mixpanel proxy.routeMatcheslearns a one-segment:paramand a:param(…)with a pattern of its own. The test fails on the oldvercel.json./api/v1(where ADR 076's request-ID checks move), the website's 404 for browsers and programs, and the 404's script hashes and framing policy.Validation
go test ./apps/cloud/launcher/: pass; the new test fails against the previousvercel.json(every junk path resolved to the server).moon run e2e:typecheck e2e:lint website:typecheck website:lint website:test website:build: pass. The CLI's telemetry test, which holds the Mixpanel rule ahead of the catch-all: 11 passed.moon run workspace:cloud(vercel devwith thisvercel.json):/api/v1/readyz,/csp-report(204), both IdP callback paths (the server's 400 for a callback without parameters),/console/runtime.jsonand the alias paths (/users/me,/flow_definitions,/schemas, withDeprecation) reach the server;/robots.txt,/.env,/wp-login.php,/userss/me,/api,/flowsand/no-such-pageget the website's new 404;/api/v1/no-such-pagethe server's page;CLOUD_URL=http://localhost:3000 turbo run console-deployment --filter=@zitadel/e2e: the new and changed routing tests pass. Four fail as they do on the base undervercel dev, for/and/changelogtoo: the redirect's query (the runbook's known case), and the shared security headers and the website's script-hash policy, which only a deployment applies.console (Preview),cli (Preview),docs (Preview)andschemas (Preview)among them, so the new routing tests hold against the real edge. Paths the suite does not cover, probed by hand throughvercel curl:/idp/github/callbackand/__nextgen/idp/github/callback: the server's 400 for a callback without parameters;/cron/events-retention: the server's 401 without the cron secret;/flow_definitions,/schemasand/auth_attempts/x: the server's 401 withDeprecation;/schemas/v1/user-schema.json: the schemas service;/flowx,/idp/githuband/robots.txt: the website's 404, which the server never sees.Release notes / changeset
Notes
/__nextgen/idp/{slug}/callbackis the IdP callback as an app's proxy forwards it; the cloud's origin may never see it, but the server mounts it, so it keeps a rule.🤖 Generated with Claude Code