Cloudflare Zero Trust — admin
Protect /admin in production with a Cloudflare Zero Trust Access Self-Hosted Application:
- Zero Trust → Access → Applications → Add Self-hosted
- Set Application domain to your Worker hostname and Path to
/admin - Add an Allow policy scoped to your identity provider and email/group
- Do not add an Access policy on
/api/v1 — clients use Bearer auth there
Full operator guide: docs/cloudflare-access-and-api-bearer.md in the repository.
Disable the workers.dev subdomain
Cloudflare automatically assigns a *.workers.dev public URL to every Worker. If that subdomain is reachable, requests to /admin bypass Zero Trust Access entirely.
In the Cloudflare dashboard → Workers & Pages → your Worker → Settings, disable the workers.dev route once your custom domain is live.
API Bearer token rotation
To rotate the API_BEARER_TOKEN secret:
- Generate a new long random token
- Run
wrangler secret put API_BEARER_TOKEN and paste the value - Update the token in all CI/CD pipeline secret variables and API clients
- Retire the old token — it is immediately invalidated on deployment
Store API_BEARER_TOKEN in secret pipeline variables — never in the repository or environment files that are committed.