Skip to content

Custom Domains

Both commands need the domain’s zone to already be on the same Cloudflare account. They edit the relevant wrangler.toml and redeploy, and Cloudflare creates the DNS record and route during that deploy. No dashboard step is needed.

Terminal window
pnpm run update -- --domain

Adds a [[routes]] entry with custom_domain = true to the root wrangler.toml and redeploys the API. It then asks whether to disable the *.workers.dev URL. The default is no: connect the domain, verify it works, and only then disable the fallback. Then point the auth URL at it:

Terminal window
pnpm run update -- --auth

--auth sets BETTER_AUTH_URL, redeploys the API, and rebuilds and redeploys the Admin Worker against the new address. The admin was built against the previous URL until you run it.

Terminal window
pnpm run update -- --admin-domain

Does the same for apps/admin/wrangler.toml, deploys the Admin Worker, then synchronizes everything on the API side that depends on the Admin app’s own public origin: it refreshes the ADMIN_URL secret (so password-reset and verification links point at the new address) and migrates CORS_ORIGINS in the root wrangler.toml — the old admin origin is replaced in place, every unrelated origin is preserved, and duplicates are never introduced. The API redeploys automatically, but only when CORS_ORIGINS actually changed. No manual CORS_ORIGINS edit needed. It never touches BETTER_AUTH_URL — that’s a separate, API-side concept (see --auth above). Safe to re-run: a second run with the same domain makes no further changes. If the Admin Worker’s own deploy fails, nothing on the API side is touched; if the API-side step fails afterward, the command reports the migration as incomplete rather than claiming success — just run it again once the underlying issue is fixed. See Authentication and CORS.

Moving the admin app to a new domain (e.g. cms.example.com → admin.example.com) frees the old hostname up for something else, but this command never removes the old route on your behalf — it only ever adds the new one. Retiring the old route (e.g. to reuse cms.example.com for a different site) is a separate, deliberate step: remove its [[routes]] block from apps/admin/wrangler.toml and redeploy.

Add --ci with one category flag and set variables. An unset variable means leave unchanged.

Terminal window
CUSTOM_DOMAIN_NEW=api.example.com DISABLE_WORKERS_DEV=true pnpm run update -- --domain --ci
ADMIN_CUSTOM_DOMAIN_NEW=admin.example.com pnpm run update -- --admin-domain --ci

Only one category flag can be given per run. To change a Worker’s *.workers.dev name instead, use pnpm run rename-worker; see the CLI reference.