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.
DATABASE_URL=postgresql://user:password@host/database?sslmode=require
JWT_SECRET=change-me-in-productionOptional (when testing uploads against real R2):
# 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):
{
"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
| App | Config | Project name | Output |
|---|---|---|---|
| Landing | apps/landing/wrangler.jsonc | cepatedge | dist/ |
| Web SPA | apps/web/wrangler.jsonc | app-cepatedge | dist/ |
| Docs | apps/docs/wrangler.jsonc | docs-cepatedge | .vitepress/dist/ |
| Git | apps/git/wrangler.jsonc | git-cepatedge | dist/ |
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.comhttps://app.cepatedge.comhttps://api.cepatedge.comhttp://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
| Issue | Check |
|---|---|
| DB connection failed | DATABASE_URL, SSL mode, Neon IP allowlist |
| 401 after login on deployed app | Custom domain on app + api; cookie domain .cepatedge.com; CORS includes app.cepatedge.com |
| Upload failed | R2 binding CEPATEDGE_STORAGE, bucket cepatedge, object key in DB |
| CORS error | Origin must be in config.cors.allowedOrigins or system-settings allowed origins |