Skip to content

Configuration

Config has three layers (highest wins in practice for production):

  1. Cloudflare Worker bindings / vars / secrets
  2. wrangler.toml [vars] and [[d1_databases]] / [[r2_buckets]]
  3. Nuxt runtimeConfig / local .env (local fallback)

Cloud resources you must create

ResourceBindingPurpose
D1DBMetadata, users, sessions, settings
R2BUCKETFile blobs

Without both, the app boots but upload/admin APIs return 503.

wrangler.toml vars

VarMeaning
R2_PUBLIC_BASE_URLR2 public root URL, no trailing slash
MAX_UPLOAD_BYTESMax file size in bytes, default 20971520 (20MB)

Optional secrets / vars (see code comments):

VarMeaning
BOOTSTRAP_ADMIN_USER / BOOTSTRAP_ADMIN_PASSOptional env-assisted first admin
RESET_KEYReserved ops hook if implemented
CLOUDFLARE_API_TOKENLocal/CI CLI only — do not put in production Worker vars or Git

Nuxt runtimeConfig

See root nuxt.config.ts:

KeyMeaning
r2PublicBaseUrlLocal fallback public base
maxUploadBytesLocal fallback size limit
corsOriginsComma-separated; empty echoes request Origin (handy for PicGo)
public.siteNameSite name
public.maxUploadMbClient-facing limit in MB

Local .env overrides example:

bash
# .env — local only; do not commit
NUXT_R2_PUBLIC_BASE_URL=https://pub-xxxx.r2.dev
NUXT_MAX_UPLOAD_BYTES=20971520

.env vs production

ScenarioNeed .env?
pnpm devOptional
Manual Cloudflare deployNo
GitHub Actions Worker deployUse Secrets, not a committed .env

Always treat Dashboard / wrangler.toml as source of truth in production.

CORS

Upload endpoints support CORS. Empty corsOrigins echoes Origin; tighten to an allowlist in production. Credentialed cross-origin clients must also handle cookies correctly.

Released under the MIT License