Skip to content

Configuration

Environment variables, Wrangler bindings, and production domain layout.

Start here: domains.md — URLs, Pages project names, cookie scope.


Worker secrets (apps/worker/.dev.vars)

Local development only — never commit this file.

bash
DATABASE_URL=postgresql://user:password@host/database?sslmode=require
JWT_SECRET=change-me-in-production

Optional (when testing uploads against real R2):

bash
# R2 S3 API credentials — only if using remote bucket from local wrangler
# Production uses the CEPATEDGE_STORAGE binding (no keys in Worker code).

Production secrets: Cloudflare dashboard → Workers → cepatedge-api → Settings → Variables / Secrets, or wrangler secret put.


Wrangler — API worker

apps/worker/wrangler.jsonc (high level):

jsonc
{
  "name": "cepatedge-api",
  "main": "src/index.ts",
  "r2_buckets": [
    { "binding": "CEPATEDGE_STORAGE", "bucket_name": "cepatedge" }
  ],
  "durable_objects": {
    "bindings": [{ "name": "CEPAT_EDGE_CACHE", "class_name": "CepatEdgeCache" }]
  }
}

Custom domain: api.cepatedge.com.


Wrangler — Cloudflare Pages apps

AppConfigProject nameOutput
Landingapps/landing/wrangler.jsonccepatedgedist/
Web SPAapps/web/wrangler.jsoncapp-cepatedgedist/
Docsapps/docs/wrangler.jsoncdocs-cepatedge.vitepress/dist/
Gitapps/git/wrangler.jsoncgit-cepatedgedist/

Deploy via root scripts (pnpm landing:deploy, pnpm web:deploy, etc.).


CORS and cookies (apps/worker/src/lib/config.ts)

Production allowed origins (CORS):

  • https://cepatedge.com
  • https://app.cepatedge.com
  • https://api.cepatedge.com
  • http://localhost:3000 / 5173 (dev)

Cookie domains: localhost, .cepatedge.com only.

Legacy *.pages.dev and *.zamdev.dev are not listed — Pages custom domains handle production traffic; auth is scoped to .cepatedge.com.

System settings cache defaults mirror CORS in apps/worker/src/lib/services/cache/system/settings/defaults.ts.


Database

  • Neon PostgreSQL + Drizzle ORM
  • Migrations: pnpm --filter @cepatedge/worker db:push
  • Schema: apps/worker/src/lib/db/schema.ts

Application limits

Upload limits and maintenance caps live in apps/worker/src/lib/config.ts (uploads section) and enforced in route handlers — not duplicated here.


Troubleshooting

IssueCheck
DB connection failedDATABASE_URL, SSL mode, Neon IP allowlist
401 after login on deployed appCustom domain on app + api; cookie domain .cepatedge.com; CORS includes app.cepatedge.com
Upload failedR2 binding CEPATEDGE_STORAGE, bucket cepatedge, object key in DB
CORS errorOrigin must be in config.cors.allowedOrigins or system-settings allowed origins