Skip to content

Cloudflare Deployment

pnpm run setup provisions and deploys everything. See Set up and deploy.

Resource Purpose
API Worker (kenresoft-cms-api by default) REST API, Better Auth, forms, cache, cron
Admin Worker (kenresoft-cms-admin by default) Dashboard, static assets only
D1 database (binding DB) All structured data
R2 bucket (binding MEDIA_BUCKET) Media and form attachments
Rate Limiting bindings Auth, recovery, forms, public reads, admin email
Cron Trigger (*/5 * * * *) Scheduled publishing, webhook retries, cache-purge work

Optional: Cloudflare Email Sending (a [[send_email]] binding) or Resend for email, and a Paystack secret for Commerce payments. There is no KV namespace. Names for the Workers, D1 and R2 are unique per Cloudflare account; setup asks for a different name if one is taken.

The API Worker’s configuration is the wrangler.toml at the repository root. The Admin Worker’s is apps/admin/wrangler.toml.

  • pnpm run setup (recommended): guided, idempotent, deploys both Workers.
  • Manual wrangler deploy: deploy the API, run migrations, build and deploy the admin, then add the admin origin to CORS_ORIGINS. The repository’s docs/DEPLOYMENT.md has the full sequence.
  • GitHub Actions: .github/workflows/deploy.yml deploys on push to main, but is inert until you set the repository variable DEPLOY_ENABLED to true, plus CLOUDFLARE_API_TOKEN, CLOUDFLARE_ACCOUNT_ID and VITE_API_URL. It never targets Kenresoft’s own account.
  • Deploy to Cloudflare button: covers the API Worker only. The Admin Worker has no equivalent button, so you still deploy it separately. Prefer setup.

GET /api/v1/openapi.json and GET /api/v1/docs (a Scalar reference) are enabled by default. Set API_DOCS_ENABLED = "false" in [vars] to make both return 404.