Skip to content

6. Environment variables

"Environment variables" are settings the app reads at runtime — like who the admins are. Some are plain settings; one kind (secrets) is for sensitive values. You set these in the Cloudflare Pages dashboard so they apply to the live site.

The settings this app uses

Name Required? What it does Example
ADMIN_EMAILS Yes Comma-separated emails that are always admins. Bootstraps the very first admin. robertbettencourt@totlcom.com
APP_ENV Yes Which environment this is. production
DEFAULT_SCHEDULE_WEEK_START Yes The day weeks start on. Locked to Wednesday for TOTLCOM. wednesday
GEMINI_API_KEY No (secret) Optional AI helpers. Leave unset to keep AI fully off. Core scheduling never uses it. (unset)
GEMINI_MODEL_ORDER No Fallback order for the optional AI. Only matters if the key above is set. gemini-2.5-pro,gemini-2.5-flash,gemini-2.5-flash-lite

These also appear in wrangler.toml

The non-secret ones (APP_ENV, DEFAULT_SCHEDULE_WEEK_START, ADMIN_EMAILS) are listed under [vars] in wrangler.toml, which is the default. Setting them in the dashboard too is the reliable way to be sure production has the right values — the dashboard wins. Set ADMIN_EMAILS in the dashboard to be safe.

Set them in the dashboard

  1. Open your Pages project → SettingsVariables and secrets (older dashboards: Environment variables).
  2. Under Production, click Add variable for each plain setting:
    • ADMIN_EMAILS = your real admin email(s), comma-separated, no spaces needed: you@totlcom.com,boss@totlcom.com
    • APP_ENV = production
    • DEFAULT_SCHEDULE_WEEK_START = wednesday
  3. Click Save.

Set ADMIN_EMAILS before relying on the app

If ADMIN_EMAILS is empty in production, no one is an admin, the Admin tab is unreachable, and you can't promote anyone. Always set your own address here first.

Secrets (only if you use optional AI)

Secrets are hidden values. The app's only optional secret is GEMINI_API_KEY, and you can skip it entirely — AI features are off by default and core scheduling never sends names or phone numbers anywhere.

If you do want the optional AI helpers, set the key as a secret (not a plain variable) either in the dashboard (mark it as a secret) or from the terminal:

npx wrangler pages secret put GEMINI_API_KEY

It prompts you to paste the value, which is then encrypted.

Make changes take effect

Environment variable changes apply on the next deploy. Trigger one:

  • the easy way — Pages project → Deployments on the latest → Retry deployment, or
  • push any commit to GitHub.

Local development settings (not production)

For running the app on your own machine, settings live in local files that are never committed: .env (copied from .env.example) and .dev.vars. In particular, .dev.vars contains DEV_ADMIN=1, which makes your local machine act as an admin during development (production never sets this). See Deploying updates → Running locally.

Run database migrations