Production
The D1 database and R2 bucket already exist (their IDs are in wrangler.jsonc). CLOUDFLARE_API_TOKEN needs the permissions listed on /setup (Zone Read, Zone Settings Edit, Email Routing Rules Edit, DNS Edit, Email Sending Edit, Workers Routes Edit, Email Routing Addresses Edit). Deploying serves mail.appneurox.com.
npx wrangler secret put EDIT_PASSCODE
npx wrangler secret put CLOUDFLARE_API_TOKEN
npm run db:migrate:remote
npm run deployThen open /setup, set the default forward address (it must be a verified Email Routing destination), and set up mail servers from /domains.
Deploy from your machine
Important
The wrangler login sees several Cloudflare accounts. Set CLOUDFLARE_ACCOUNT_ID to the APPNEURAL account in your shell first, or Wrangler stops to ask.
npm install
npm run db:migrate:remote
npm run deploySet the secrets once (they stay across deploys):
npx wrangler secret put EDIT_PASSCODEDatabase migrations
Applied in order from migrations/:
| # | Migration |
|---|---|
| 0001 | create mail |
| 0002 | seed account domains |
| 0003 | mail server |
Check that it is live
curl https://mail.appneurox.com/healthIt answers {"status":"ok"} when the Worker and its database are up.