Repository navigation
feat!: call the API under /api/v1 - #2359
Conversation
Checking the proposal against the code showed that more moves than the mount and the client base URL. The project secret, the SDKs' session-cookie handling, the dev proxies the CLI writes and the production proxies the docs describe all decide by exact path; so do the session no-store rule and the audit's route fallback in the server. The amendment keeps the probes in the spec and at the root for good, gives the root alias a Deprecation header and a measure of its traffic, has every path check accept both spellings until 1.0.0 (with a doctor --fix migration for scaffolded proxies), and orders the rollout so every mix of versions keeps working. The design docs say the prefix is accepted but not shipped. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Every first-party client now calls the resource API under /api/v1 (ADR 077), which the server serves; the root paths keep answering, deprecated, until 1.0.0. - @zitadel/api: the generated operations call getApiBaseUrl(), the proxy path or server URL followed by API_PREFIX; apiBaseUrl() keeps a single prefix when a base already ends in it. A 404 req.not_found says the server may predate the prefix. - Hand-built calls follow: sdk-core's session check, retire probe and revoke, sdk-next's getSession(), the CLI's local sign-in, the testing kit's flow calls and the console's dev-real scripts. - CLI: zitadel api builds URLs with the prefix and accepts a path typed with it; the v2 dev-proxy migration becomes infrastructure wiring, so zitadel doctor fails on a v2 proxy until doctor --fix moves it to v3. - Console: the API base is "" under the dev server too; the Vite proxy forwards /api/v1 unchanged. The embedded e2e lane now asserts every API call goes under /api/v1. - api-mock answers its custom routes on both spellings, like the server. - Tests that pin URLs, docs, SKILL.md and the console ADRs follow; ADR 077 is Implemented and the design docs say the prefix shipped. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
🦋 Changeset detectedLatest commit: 160c81d The changes in this PR will be included in the next version bump. This PR includes changesets to release 24 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Brings in #2358's server, so CI and this branch's Vercel preview run against a server that serves /api/v1. The PR's base is that branch, so its diff is unchanged. When #2357 and #2358 have merged, rebase with: git rebase --onto origin/main claude/api-v1-gates-and-server Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Stacks this PR on #2358 instead of the merge branch of #2357 and #2358, and brings in main through them. Conflicts: - ADR 077, its README row and the design docs keep this PR's "Implemented" and "shipped" wording, with #2356's new section 5 text and main's other edits to the resource map. - The console's Vite config is main's, restructured for the cloud's add-on, with this PR's proxy for /api/v1; the test base moved to vitest.config.ts, which now names the origin. The console's specs that main added or changed call /api/v1, as the rest do. - sdk-core's revokeSession (ADR 083, main) asks for the CSRF token and revokes under the prefix; its tests and the six server SDKs' tests take main's cookie names and this PR's prefixed URLs. - The scaffold guidance, sdk-next's docs, the CLI's SKILL.md, the console README and src/api/zitadel.ts take main's text with this PR's /api/v1 paths. The CLI's local-server tests and console-real's response match take main's cases on the prefixed paths. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Code main added since this PR was written still called the root paths: - The hosted cloud's functions read /users/me and /users/me/teams from the server; they now read them under the prefix. The sign-in widget the console's cloud add-on points at them calls /cloud/zitadel/api/v1/..., which they forward unchanged, and #2357's bot check reads both spellings. - Tests main added mock the server at the root: the CLI's policy, rollback, env add, preview list, setup deploy and issuer-origin tests, the console's releases and deployments specs, and the server SDKs' CSRF read before a sign-out revoke. They mock the prefix now. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Brings in #2358's fix for the docs playground's session reads. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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 breaking API migration spans roughly 70 files and hinges on runtime cross-package behavior and upgrade ordering that cannot be confirmed through static review alone.
No open issues 🎉
What changed in this PR
This is the final PR in a stacked series (#2356 → #2357 → #2358 → this) implementing ADR 077: every first-party client now calls the resource API under /api/v1, matching where the server (shipped in #2358) serves it. The server continues answering the old root paths, deprecated, until 1.0.0, so mixed client/server versions keep working (a self-hosted server must be upgraded before its apps). The change centers on a new apiBaseUrl()/getApiBaseUrl() helper in @zitadel/api that the generated client and every hand-built call now use; the rest is coordinated propagation through the SDKs, components, console, CLI, cloud functions, docs, ADRs, and a large set of pinned-URL tests.
Changes:
- Add
apiBaseUrl(base)/getApiBaseUrl()in@zitadel/api(strip trailing slashes, keep a single/api/v1) and wire the orval client, hand-built SDK/CLI/testing calls, and console/cloud-functions through it. - Surface a
req.not_foundhint ("server older than this client/SDK") incustomFetch,sdk-core,sdk-next, and the CLI error/SKILL guidance; turn the scaffolded v2 dev-proxy from a doctor warning into a failure. - Flip the console dev proxy to forward
/api/v1unchanged (base now""in dev too), update all MSW/e2e/test URLs, and mark ADR 077 Implemented across docs; add the@zitadel/*changeset.
Review notes: I verified the migration is complete (no non-test source still hand-builds a root API URL), the proxy/base/dual-serving logic is internally consistent, and the changeset correctly omits private packages (@zitadel/cloud-functions, @zitadel/api-mock). No blocking issues found. Correctness of the end-to-end wiring ultimately rests on the integration/e2e suites described in the PR, which can't be run here.
| File | Description |
|---|---|
packages/api/src/runtime/base-url.ts |
New apiBaseUrl()/getApiBaseUrl() prefix helpers |
packages/api/src/runtime/base-url.spec.ts |
Tests the prefix-once behavior across base shapes |
packages/api/src/runtime/fetch.ts |
req.not_found 404 message naming the prefix |
packages/api/src/runtime/fetch.spec.ts |
Tests the new 404 messaging |
packages/api/orval.config.ts |
Generated client base switched to getApiBaseUrl() |
packages/api/README.md |
Documents /api/v1 base and apiBaseUrl() |
packages/sdk-next/src/session.ts |
getSession() reads {proxyPath}/api/v1/sessions/me + hint |
packages/sdk-next/src/__tests__/*, README.md, SKILL.md |
Prefix in tests/docs |
packages/sdk-core/src/middleware.ts |
Hand-built session probe/revoke use apiBaseUrl(); req.not_found undecided |
packages/sdk-core/src/middleware.spec.ts |
Prefix + older-server coverage |
packages/sdk-{nuxt,sveltekit,solid-start,qwik,qwik-router,tanstack-start}/** |
Proxy test URLs moved to /api/v1 (source proxies forward unchanged) |
packages/components/src/orchestrator/*.spec.ts |
Session/logout/SSO MSW URLs under /api/v1 |
packages/testing/src/session.ts + tests |
flowFetch uses apiBaseUrl(); seed/bootstrap test URLs |
packages/api-mock/src/server.ts |
Express custom routes answer both spellings via apiPaths() |
apps/console/vite.config.ts, src/api/zitadel.ts, api-base.spec.ts, vite-env.d.ts, vitest.config.ts, test-setup.ts, test/msw.ts |
Base "", proxy forwards /api/v1 unchanged |
apps/console/src/routes/**, components/** specs |
MSW handler URLs moved to /api/v1 |
apps/console/scripts/dev-real*.mts |
Dev-real seeding uses apiBaseUrl() |
apps/console/README.md, AGENTS.md, docs/adrs/0002,0003 |
Console docs/ADRs updated |
apps/cloud-functions/src/zitadel.ts, sign-in.ts + specs |
API_PREFIX defined in zitadel.ts, directory reads under prefix |
apps/cli/src/lib/api/request.ts, operations.ts |
urlOf uses apiBaseUrl(); resolveTarget accepts prefixed paths |
apps/cli/src/lib/local-server/sign-in.ts, errors.ts |
Session exchange prefixed; error hint updated |
apps/cli/src/lib/orca/patchers/rule/{vite-support,angular}*, guidance*, react/index.ts |
v2 proxy now infrastructure (doctor fails); guidance prefixed |
apps/cli/tests/unit/** |
CLI test URLs, docs regex (?<!\/api)\/v1\/, doctor warn→fail |
apps/cli/skills/zitadel-cli/SKILL.md |
Documents prefix handling for zitadel api |
apps/docs/content/docs/sdks/{proxy,api-client}.mdx |
SDK docs describe /api/v1 |
docs/design/{glossary,api/*}.md, docs/adrs/README.md, 077-api-path-prefix.md |
ADR 077 marked Implemented/shipped |
e2e/console/**, e2e/journey/src/claim.spec.ts |
E2e assertions/probes under /api/v1 |
.changeset/clients-call-api-v1.md |
Minor changeset for the affected published packages |
Review effort: Balanced
Brings in #2358's spec checks and #2357's shared prefix. The cloud functions' sign-in forwarder and directory both import API_PREFIX from @zitadel/api now, so the constant this branch had added to zitadel.ts goes; base-url.spec.ts keeps this branch's imports beside the new test. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
With VITE_CONSOLE_API_BASE=/api/v1 (or /gateway/api/v1) the client keeps a single prefix, but the dev proxy stripped the whole configured base, so /api/v1/users/me reached the server as /users/me: the deprecated root alias answered, and would stop at 1.0.0. The proxy's route now reads the base with the client's own apiBaseUrl and strips only what comes before the prefix; the API-base spec pins it for five bases. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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>
Since #2359 the widget calls /cloud/zitadel/api/v1/flow…, but BotID's client still marked /cloud/zitadel/flow…. The functions' checkBotId() read every unmarked flow write as a bot and answered 403 auth.bot_suspected, so sign-in and sign-up failed on every cloud preview before the first step loaded. The paths now live in @zitadel/cloud-functions/contract, built with apiBaseUrl(), the function the widget's client uses, and a test checks that every path the client marks is one the functions check. Production is unchanged: it still starts no BotID client and skips the hop. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Context
/api/v1. GitHub lands the stack bottom up.zitadel startandsetupcheck the version of a local server they find running.Summary
Every first-party client calls the resource API under
/api/v1. The server keeps answering the root paths, deprecated, until 1.0.0.@zitadel/api. The generated operations callgetApiBaseUrl(): the proxy path or server URL, thenAPI_PREFIX.apiBaseUrl(base)strips trailing slashes and keeps a single prefix when the base already ends in it.customFetchsays, on a404 req.not_found, that a server older than the client does not serve the API under/api/v1. ThroughcreateZitadelClient/configureZitadelthis moves the components, the SDKs' browser calls, the CLI, the test kit, the docs samples and Storybook.@zitadel/sdk-core: the opaque-session check, the shared-session retire probe and its revoke; the check's log names areq.not_foundanswer.@zitadel/sdk-next:getSession()reads{proxyPath}/api/v1/sessions/me, with the same hint.@zitadel/testing: the flow calls ofseedSession().dev-realscripts and the journey lane's session read.zitadel apibuilds<server>/api/v1/<spec path>(also for--dry-runand--curl), takes a path typed with the prefix, and itsreq.not_foundhint names a server from before the move. The v2 dev-proxy migration from feat: accept /api/v1 paths in the SDK and dev-proxy gates #2357 becomesinfrastructurewiring, Vite and Angular alike: from this release a v2 proxy breaks sign-in, sozitadel doctorfails on it untilzitadel doctor --fix. SKILL.md says where the API lives and howzitadel apitreats the prefix.""under the dev server too, as in the build. The Vite proxy forwards/api/v1unchanged instead of stripping/api. AVITE_CONSOLE_API_BASEstill goes in front of the/api/v1, and the proxy strips it. Specs and MSW handlers use/api/v1, and the shared MSW server still fails any request no handler answers. The embedded e2e lane's "never an/apiprefix" test becomes "every API call is under/api/v1", restricted to same-origin fetch/XHR, since the root still answers and only this would notice a call there. AGENTS.md, README, console ADR 0002/0003 and the e2e README follow./users/meand/users/me/teamsunder the prefix. The console's cloud add-on points the sign-in widget at/cloud/zitadel, so the widget calls/cloud/zitadel/api/v1/…, which the functions forward unchanged; feat: accept /api/v1 paths in the SDK and dev-proxy gates #2357 makes their bot check read both spellings.@zitadel/api-mock. Its Express routes (session exchange, session read and revoke, CSRF read, claim completion) answer both spellings, like the server; the MSW handlers were*/…already. The conformance spec calls the prefix and checks the root spelling still answers.resources,sign-in,claim-as-admin, origin, rollback, env, call/curl/request/api,api-coverage, setup's fake server), the components' session, logout and SSO specs, the six server SDKs' session paths, sdk-next'sauth()andgetSession(), sdk-nuxt, sdk-tanstack-start, sdk-qwik, the test kit's unit tests. The CLI docs test bans a bare/v1/but allows/api/v1/.@zitadel/api's and sdk-next's READMEs and sdk-next's SKILL.md. ADR 077 is Implemented, and the glossary, the API design guide and the resource map say the prefix shipped.Validation
On this branch with the whole stack and
mainmerged in (566d43e, and 4adc6b1 before #2358's docs fix):moon ci :lint :typecheck :build :test: everything passes exceptserver:test-postgres, which needs Docker (feat: serve the API under /api/v1 and deprecate the root paths #2358 ran the Postgres lane another way). Before 4adc6b1 it also failed on fixturesmainadded at the root paths and on CLI suites timing out under the load; after the fix,moon runof the failed tasks passes: sdk-next 254, sdk-nuxt 233, sdk-sveltekit 134, sdk-solid-start 135, sdk-qwik-router 134, sdk-tanstack-start 156, console 493 and lint, cloud-functions 67, and the 16 CLI suites (all pass when run alone).moon run e2e:journey -- --ci, against tarballs packed from this branch and installed from a local registry: all 13 lanes pass (next, nuxt, react, vue, angular, solid, svelte and qwik fresh apps, passkey, pre-existing next and nuxt, the test kit, remote https), and thecli:testit runs passes 5167 tests. The React lane, run again with--keep, left its local server's log: every API request is under/api/v1(the CLI's setup, deploy and claim, the app's sign-up and sign-in, the console's claim page), and only/readyzat the root.moon run server:build(console embedded), started with nothing but an address, a public base and a data directory./api/v1/users/meanswers 401 withoutDeprecation,/users/me401 withDeprecation: @1792886400andLink,/livez,/readyzand/api/v1/livez200 without it,/api/v1,/api/v1/nopeand/nopeADR 076's 404, and the embedded console's first API call isGET /api/v1/sessions/me.cli (Preview),console (Preview)andschemas (Preview)pass;docs (Preview)failed on the playground testsmainadded, which feat: serve the API under /api/v1 and deprecate the root paths #2358 fixes (6a27e50, merged here). The preview's request log over the checks shows every first-party API call under/api/v1: the CLI suite's setup, deploy, variables, origins, rollback and claim, the cloud console's sign-up widget through/cloud/zitadel/api/v1/…, and the cloud functions' reads of/users/meand/users/me/teams. The only root-path calls are the probes of my own spot check. CI'sfull-prpassed at 4adc6b1.Release notes / changeset
.changeset/clients-call-api-v1.md—@zitadel/api,@zitadel/cli,@zitadel/sdk-core,@zitadel/sdk-next,@zitadel/server(the console ships in it),@zitadel/testingminor. The SDKs, the components, the console and the CLI call the API under/api/v1. Breaking: upgrade a self-hosted server before its apps; runzitadel doctor --fixin an SPA an earlier setup scaffolded; a hand-written SPA production proxy must add the project secret toPOST /api/v1/sessions/exchange; the root paths answer withDeprecationuntil 1.0.0.Notes
VITE_CONSOLE_API_BASE, so a base ending in/api/v1(/api/v1,/gateway/api/v1) sent/api/v1/users/meto the server as/users/me, which only the deprecated root alias answered.devApiRoute(vite.config.ts) now reads the base with the client'sapiBaseUrland strips only what comes before the prefix;api-base.spec.tspins five bases and a look-alike. The cloud functions' directory importsAPI_PREFIXtoo. Checked:moon run console:test console:lint console:typecheck api:test cloud-functions:test cloud-functions:typecheck cloud-functions:lint cli:typecheck cli:lint docs:typecheck(console: 499 passed) and the CLI's patcher and doctor tests.@zitadel/api's published MSW handlers stay*/…, so they match either spelling through 0.x.@zitadel/api-mock(fail a test whose API call is not under/api/v1) is not built. Every first-party call now goes throughapiBaseUrl()or the generated client. The console's MSW server fails unhandled requests, the other suites pin exact URLs, and the embedded e2e lane checks the console in a real browser, so a missed call site fails a test today. Say if you still want the guard.🤖 Generated with Claude Code