This project compiles the Next.js 15 App Router app into a Cloudflare Worker using @opennextjs/cloudflare. The Worker entry (.open-next/worker.js) and static assets (.open-next/assets) are deployed by Wrangler with the configuration in wrangler.jsonc. Database access uses Cloudflare D1 (src/db/index.ts), and optional file storage is S3-compatible via src/storage/provider/s3.ts.
Use this guide as an end-to-end deployment checklist. Each section maps to a concrete action you must complete before running pnpm deploy.
Create an R2 bucket and generate an S3-compatible access key.
Populate STORAGE_REGION, STORAGE_BUCKET_NAME, STORAGE_ACCESS_KEY_ID, STORAGE_SECRET_ACCESS_KEY, STORAGE_ENDPOINT, and STORAGE_PUBLIC_URL as secrets (see next section). The endpoint should include the bucket domain expected by s3mini (https://<account>.r2.cloudflarestorage.com or your custom domain).
If you prefer using an R2 binding instead of S3-compatible keys, add it under r2_buckets in wrangler.jsonc and adapt src/storage/provider/s3.ts.
Split variables between Wrangler vars (non-secret) and secrets (sensitive):
Non-sensitive config can be set in wrangler.jsonc under "vars".
Secrets (API keys, OAuth secrets, BETTER_AUTH_SECRET, etc.) must be stored with Wrangler:
wrangler secret put BETTER_AUTH_SECRETwrangler secret put STRIPE_SECRET_KEYwrangler secret put RESEND_API_KEY# ...repeat for all keys listed in cloudflare-env.d.ts
If you use the automated credit distributor (src/app/api/distribute-credits/route.ts), store CRON_JOBS_USERNAME and CRON_JOBS_PASSWORD as secrets and add a Cloudflare Cron Trigger hitting that route (Workers → Triggers).
Configure Webhooks (Stripe, Resend, Feishu, Discord) to point at your deployed domain once it is live.
Worker fails with DB not configured: confirm d1_databases entry in wrangler.jsonc and that the Worker was deployed with the binding.
Requests error while fetching files: double-check S3/R2 credentials and the bucket endpoint format expected by s3mini.
Missing environment variables: cross-reference cloudflare-env.d.ts to ensure every required key is configured as a secret or var.
Migrations blocked: check that the API token includes Account.D1 permissions and that CLOUDFLARE_ACCOUNT_ID/CLOUDFLARE_D1_DATABASE_ID are exported in your shell session.