Cloudflare tutor

A morning desk for Kotha · Gold Coast

· Australia/Brisbane · Lesson

Env vars and secrets: plain config versus hidden values

Environment variables and secrets

What it is

A Worker can read values through its env object at runtime. Two common kinds are environment variables (often called vars) and secrets. Both show up in your script the same way — for example env.API_HOST or env.API_KEY — but they are stored and shown differently.

Environment variables are plain text config. You set them in the Cloudflare dashboard under the Worker’s Settings, or in wrangler.toml under a [vars] block. Their names and values are visible when you open the project. Use them for non-secret settings: a public API base URL, a feature flag string, a site title, or which mode the app is in.

Secrets are also values on env, but Cloudflare encrypts them and does not show the value again after you save. You set a secret in the dashboard (Settings → Variables and Secrets → Encrypt) or with wrangler secret put NAME. Use secrets for API tokens, webhook signing keys, and any string that must not sit in a config file or a screenshot.

Local development uses a separate file such as .dev.vars (or .env) next to wrangler.toml so you can test secrets without putting them in git. Do not put real tokens in [vars] in wrangler.toml — that file is meant to be readable and often committed.

Why it matters

Small Workers on kosan.xyz and drkotha.com often call outside APIs, OpenRouter, or webhooks. Hard-coding a token in worker.js, or pasting it into a plain var, leaks it into deploys, backups, and chat logs. Secrets keep the live value off the page and out of the repo.

Plain vars still matter. A hostname, a public docs URL, or a LESSON_MODE style flag is safer as a var you can read and change without rotating a credential. Mixing the two wrongly either exposes a secret or makes ordinary config harder to edit.

For a GP stack with many small Workers, each Worker has its own vars and secrets. Changing cloudflare-tutor does not change triage.kosan.xyz or another app. Always open the Worker you mean before you add or rotate anything.

On your account

This tutor Worker (cloudflare-tutor on cloudflare.kosan.xyz) currently needs no API keys: the lessons live in worker.js. Its wrangler.toml has name, routes, and compatibility_date, and no [vars] block and no secrets. That is normal for a static lesson desk.

Contrast that with an app Worker that calls a model API or stores a webhook secret. There you would keep the model base URL or a public site name in [vars] or dashboard plaintext variables, and put the API token only as a secret named something like OPENROUTER_API_KEY. The script reads both from env; only the secret stays hidden after save.

Other kosan.xyz and drkotha.com Workers follow the same split: config that is fine in a file goes in vars; anything that must stay private goes in secrets for that Worker alone. This lesson does not add vars or secrets to cloudflare-tutor — it only teaches you where to look.

Do this yourself

These stay in the dashboard, on your side. This site does not change DNS, routes, or other Workers.

  1. Open the Cloudflare dashboard → Workers & Pages → cloudflare-tutor → Settings → Variables and Secrets (wording may say Environment variables). Confirm whether any plaintext variables or secrets are listed for this Worker. Read only. Do not add, edit, or delete anything on cloudflare-tutor.
  2. Optional throwaway only: create a new Worker named only tutor-env-lesson, open its Variables and Secrets, add one plaintext variable TUTOR_FLAG with value lesson5, then add one encrypted secret TUTOR_SECRET with any short throwaway string. Confirm the secret value is no longer visible after save. Delete that same Worker when finished. Never set or change secrets on ainews, aiweekly, cloudflare-tutor, or other live apps.