Skip to content

build(deploy): route only the server's own paths to it in the cloud - #2566

Merged
fforootd merged 4 commits into
claude/api-v1-clientsfrom
claude/api-v1-cloud-routes
Nov 1, 2026
Merged

fforootd merged 4 commits into
claude/api-v1-clientsfrom
claude/api-v1-cloud-routes

Conversation

@fforootd

@fforootd fforootd commented Nov 1, 2026 •

Copy link
Copy Markdown
Member

Context

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-retention and 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.
  • The website's 404 answers what nothing serves, so it draws ADR 076 §4's anatomy and copy: "Error 404", "Page not found", "There is nothing at this address…", and the start page and the docs as the ways on.
  • ADR 076 is amended: §2 says the cloud routes the server its own paths and the website every other, §4 lists the website's page, and the two rejected alternatives (routing by name, unmatched paths to the website) say why they now hold. ADR 077 §5 (Cloud), the ADR index row, ADRs 081 (the future /oauth/ namespace gets a rule when it ships) and 084, the cloud runbook and README, and the website's AGENTS.md follow.
  • Tests.
    • apps/cloud/launcher: a new test resolves each of the server's paths through vercel.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. routeMatches learns a one-segment :param and a :param(…) with a pattern of its own. The test fails on the old vercel.json.
    • The console's deployment suite checks that the server answers its root paths with its request ID, that junk paths get the website's 404 without it, the server's page and envelope for an unknown path under /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 previous vercel.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 dev with this vercel.json):
    • the probes, /api/v1/readyz, /csp-report (204), both IdP callback paths (the server's 400 for a callback without parameters), /console/runtime.json and the alias paths (/users/me, /flow_definitions, /schemas, with Deprecation) reach the server;
    • /robots.txt, /.env, /wp-login.php, /userss/me, /api, /flows and /no-such-page get the website's new 404; /api/v1/no-such-page the 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 under vercel dev, for / and /changelog too: 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.
  • This PR's preview (3854e89), with Vercel's own routing: every check passes, console (Preview), cli (Preview), docs (Preview) and schemas (Preview) among them, so the new routing tests hold against the real edge. Paths the suite does not cover, probed by hand through vercel curl:
    • /idp/github/callback and /__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, /schemas and /auth_attempts/x: the server's 401 with Deprecation; /schemas/v1/user-schema.json: the schemas service;
    • /flowx, /idp/github and /robots.txt: the website's 404, which the server never sees.

Release notes / changeset

  • No changeset required — no shipped behavior changed. Only the hosted cloud's routing, the private website app, tests and docs change.

Notes

  • /__nextgen/idp/{slug}/callback is 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.
  • A self-hosted server is unchanged: it still answers every path itself, with ADR 076's page or envelope.
  • When the alias goes at GA, its rule goes with it, and the launcher test's list of names.

🤖 Generated with Claude Code

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>
@vercel

vercel Bot commented Nov 1, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
cloud Ready Ready Preview Nov 1, 2026 3:44am UTC

Request Review

@github-actions

github-actions Bot commented Nov 1, 2026 •

Copy link
Copy Markdown
Contributor

⚠️ No Changeset found

Latest commit: ac325cc

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@fforootd
fforootd marked this pull request as ready for review November 1, 2026 00:16
Copilot AI balanced review requested due to automatic review settings November 1, 2026 00:16
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 1, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
🔒 Security Review ✅ Completed 2026-11-01T00:22:59.592429Z 3854e89 Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 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.json routing: server gets its own paths + a named-resource rule; the /(.*) catch-all now goes to the website.
  • Rework the website's app/not-found.tsx to ADR 076 §4's 404 anatomy/copy ("Error 404" / "Page not found" / start-page + docs links).
  • Expand tests (apps/cloud/launcher/main_test.go route-resolution test with a richer routePattern, and the console deployment routes.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>
@fforootd
fforootd added this pull request to the merge queue Nov 1, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue because a pull request earlier in the stack was removed Nov 1, 2026
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@fforootd
fforootd added this pull request to the merge queue Nov 1, 2026
Merged via the queue into main with commit fac67ac Nov 1, 2026
26 of 34 checks passed
@fforootd
fforootd deleted the claude/api-v1-cloud-routes branch November 1, 2026 03:58
@github-project-automation github-project-automation Bot moved this from Inbox to Done in Engineering Kanban Nov 1, 2026
fforootd added a commit that referenced this pull request Nov 1, 2026
…-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>
fforootd added a commit that referenced this pull request Nov 1, 2026
#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>

This branch was successfully deployed

1 active deployment
Preview — ac325cc0 Deployed Nov 1, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

2 participants