Deployment guide
Live behavior = Astro static output + gateway worker + image worker + Cloudflare Access and DNS configuration. Staging and production differ in wrangler.gateway.toml (worker names, routes, AUTH_WORKER_VERIFY_URL).
Recommended deploy order
Section titled “Recommended deploy order”- Auth worker (platform auth verify endpoint—ensure the URL configured in gateway matches what you deployed).
- Gateway worker (
workers/wrangler.gateway.toml) — session, logout, protected paths,/api/*delegation. - Astro build + static publish —
yarn workspace cosmos-digital-services build(orbuild:stagingfor staging mode). - Image worker (
workers/wrangler.image.toml) — after or with static deploy; must match hostname routes.
From package.json, composite flows include worker:deploy (gateway + image) and deploy (runs npm run build then worker deploy—from monorepo root prefer yarn workspace cosmos-digital-services build then worker scripts for consistency with Yarn 4).
Staging vs production
Section titled “Staging vs production”- Use
wrangler deploy --env staging/--env production(or your team’s equivalent) so the correct[env.*.vars]block applies. - Verify
AUTH_WORKER_VERIFY_URLfor the target environment matches the auth worker you intend (seeworkers/wrangler.gateway.toml).
Verification checklist
Section titled “Verification checklist”After deploy:
GET /api/auth/sessionreturns JSON (not HTML) when the gateway route is active for that hostname./portal(or another protected path) requires auth—unauthenticated users hit/login?redirect=..../portal/outgoing-mailreachesPUBLIC_OUTGOING_MAIL_WORKER_URLwhen authenticated; unauthenticated users are redirected to login.- Header toggles between Login and Logout after Access completes and session returns
success: true. - Worker logs show auth verification traffic when exercising session and protected pages.
- Images with resize query params still hit the image worker routes (correct extension +
widthquery per Worker flow).
Rollback triggers
Section titled “Rollback triggers”- Session endpoint returns HTML or 404 for
/api/auth/session. - Mass redirect to login on public routes (check gateway routes and
PROTECTED_PATH_PREFIXES). - CSP or CORS errors blocking session or mail after
_headerschange. - Image routes returning wrong content or 5xx after image worker or route change.
First actions: revert the last worker or _headers deploy, confirm Wrangler routes for the hostname, confirm AUTH_WORKER_VERIFY_URL for that environment.
Further reading
Section titled “Further reading”- App
README.md— detailed env, Access, and mail worker notes. - Troubleshooting — symptom-based fixes.
- Configuration reference — blast radius by file.