DocsConnect and secure
Domains and URLs
Rename the workers.dev URL, move to a custom domain, and the three things to update when the hostname changes.
setup deploys to <worker>.<account-subdomain>.workers.dev and stores that URL
as APP_URL.
The workers.dev URL
- The account subdomain. Dashboard → Workers & Pages → Change next to Your subdomain. This is account-wide: every Worker you run moves at once, so the hostname of this instance changes too.
- The Worker name.
npm run setup -- --name my-cogsend, ornameinwrangler.personal.jsonc, moves this app tomy-cogsend.<subdomain>.workers.dev. Renaming deploys a new Worker: the old one keeps its URL, its secrets and its cron trigger until you delete it (and both count against the five-trigger free-plan limit meanwhile). - Turn the URL off.
"workers_dev": falsein the config removes it, so only a custom domain (or a route) can reach the app.
A custom domain
The hostname’s zone has to be in the same Cloudflare account. Add it under
Workers & Pages → your Worker → Settings → Domains & Routes → Add → Custom
Domain (newer dashboards have a Domains tab with the same flow) and enter
cogsend.example.com, or an apex like cogsend.com. Cloudflare writes the DNS
record and provisions the certificate; the workers.dev URL keeps answering
unless you turn it off.
Or keep the routing in config, in wrangler.personal.jsonc so upstream never
sees it:
"routes": [{ "pattern": "cogsend.example.com", "custom_domain": true }],
"workers_dev": false
npm run deploy then provisions the domain and drops the workers.dev URL. If the
hostname already serves something else, use a route instead of a custom domain —
{ "pattern": "cogsend.example.com/*", "zone_name": "example.com" } — which needs
a proxied DNS record.
After the hostname changes
-
Pin
APP_URLto the new origin. Left unset the app follows the host each request arrives on, but a pinned value does not follow a hostname change, and OAuth redirect URIs and signed media URLs are built from whatever it holds.node scripts/wrangler.mjs secret put APP_URLnpm run secrets:put APP_URLuploads it from.dev.varsinstead. Re-runningsetupleaves an existingAPP_URLalone, but it will pin the workers.dev URL again if the secret is missing. -
Re-register the redirect URI in every OAuth app you created — LinkedIn, Threads, X — as
https://<new-host>/api/connections/<platform>/callback; a provider whose registered URI no longer matches answers with a redirect error. Mastodon and Bluesky keep working: their tokens are stored, and the redirect URI is only used while connecting. -
Point an external pinger at the new host. The Worker’s own cron trigger calls the app in-process, so it is unaffected.
-
Confirm with
npm run doctor -- --app-url https://<new-host>.
Where to go next
- Configuration —
APP_URL, and the rest of what the instance reads. - OAuth apps — the redirect URIs to register again after a move.
- Cloudflare Access — an extra gate in front of the new hostname.