Skip to content

Troubleshooting

SymptomProbable causeWhat to checkFix direction
/api/auth/session returns HTML or client JSON parse errorsGateway worker route missing or wrong host/envwrangler.gateway.toml routes for current hostname; whether request hits static bucket onlyAdd/fix routes; redeploy gateway
/portal/outgoing-mail loops to loginNo Access token, verify URL wrong, or path not protected consistentlyCloudflare Access for hostname; AUTH_WORKER_VERIFY_URL; PROTECTED_PATH_PREFIXES and gateway routesAlign Access + gateway config; fix verify URL for env
Header stays Login after you expect authSession not success: true, layout script error, or missing JWT/cookieBrowser network tab for /api/auth/session; console errors; Access cookie presenceFix worker verify; fix CSP/connect; fix Access app scope
Outgoing mail fails after authWrong PUBLIC_OUTGOING_MAIL_WORKER_URL, CSP/CORS, or Resend/upstream_headers connect-src / form-action; worker logs; mail worker AccessCorrect env URL; relax CSP only as needed; check mail worker
Images skip optimizationRoute pattern omits extension or optimizer disabledwrangler.image.toml routes; ENABLE_IMAGE_RESIZING; URL missing width queryAdjust routes; enable flag; use supported query contract
Entire site shows maintenanceMaintenance flag onPUBLIC_MAINTENANCE_MODE in .env / build envSet to false and rebuild/redeploy
  • Widget errors: confirm PUBLIC_TURNSTILE_SITEKEY matches the sitekey for the environment; domain allowlist in Cloudflare Turnstile.
  • Server validation failures: TURNSTILE_SECRET_KEY must match the widget’s sitekey account; check for staging vs production mix-ups.

Symptoms: blocked fetch to session, mail worker, or analytics. Inspect browser console for CSP violation messages. Compare requested origin to Content-Security-Policy in public/_headers (connect-src, form-action, script-src, frame-src for Turnstile).

  • Build-time: Astro PUBLIC_* undefined → features silently disabled or broken. Check .env and deployment env injection.
  • Worker: Missing AUTH_WORKER_VERIFY_URL falls back to code default—may be wrong for staging; always verify Wrangler [vars].