Skip to content

Environment variables

These are typically set in apps/cosmos/digital-services/.env (local) or your deployment environment for the static build. PUBLIC_* are exposed to client bundles; never put secrets in PUBLIC_*.

VariableScopeLikely sourceUsed for
PUBLIC_SITE_URLBrowser-safe.envOptional site URL hints (see src/env.d.ts).
PUBLIC_CONTACT_FORM_WORKER_URLBrowser-safe.envContact form POST target.
PUBLIC_TURNSTILE_SITEKEYBrowser-safe.envCloudflare Turnstile widget.
PUBLIC_MAINTENANCE_MODEBrowser-safe.envWhen true, Astro middleware rewrites most routes to /maintenance.
PUBLIC_OUTGOING_MAIL_WORKER_URLBrowser-safe.env/portal/outgoing-mail authenticated POST target.
PUBLIC_OUTGOING_MAIL_ACCESS_DEV_BYPASS_TOKENBrowser-safe (sensitive in practice).envDev/local header bypass for Access-protected mail worker flows.
TURNSTILE_SECRET_KEYSecret.env / deployServer-side Turnstile validation.
RESEND_API_KEYSecret.env / workerOutbound mail provider (where used by app/workers).
FROM_EMAILSecret/config.env / workerDefault sender.
TO_EMAILSecret/config.env / workerDefault recipient.

See also README.md in the app for example .env blocks and mail worker split (PUBLIC_CONTACT_FORM_WORKER_URL vs PUBLIC_OUTGOING_MAIL_WORKER_URL).

Set in workers/wrangler.gateway.toml under [vars], [env.production.vars], or [env.staging.vars].

VariableScopeUsed for
AUTH_WORKER_VERIFY_URLWorker-onlyAuth token verification endpoint (POST from gateway).
PROTECTED_PATH_PREFIXESWorker-onlyComma-separated prefixes (e.g. /portal,/admin) requiring verified token before static fetch.

Set in workers/wrangler.image.toml.

VariableScopeUsed for
ENABLE_IMAGE_RESIZINGWorker-onlyFeature toggle string consumed by edge-utils image pipeline.

Environment matrix (staging vs production)

Section titled “Environment matrix (staging vs production)”
  • AUTH_WORKER_VERIFY_URL differs between [env.staging.vars] and [env.production.vars] in wrangler.gateway.toml. Using the wrong URL for the hostname is a common source of “auth works in prod but not staging” (or the reverse).
  • Staging hostnames use parallel route entries in both gateway and image Wrangler configs (e.g. staging.cosmosdigitalservices.com).

apps/cosmos/digital-services/src/env.d.ts documents Astro ImportMetaEnv for PUBLIC_* variables but does not list server-only secrets such as TURNSTILE_SECRET_KEY (they may still be read at build or server boundaries). AUTH_WORKER_VERIFY_URL and PROTECTED_PATH_PREFIXES are not in that file—they exist only in Wrangler. Treat this page plus README.md and Wrangler TOML as the operational catalog until typings are expanded.

  • Never commit real .env files; use team secret storage for CI/deploy.
  • Rotate Turnstile, Resend, and any bypass tokens on leak suspicion.
  • Prefer least exposure: keep mail and auth endpoints Access-protected as documented in the app README.md.