Deploy to Cloudflare
Create your Cloudflare resources, configure the production URL, and publish your website
Publish the site to your own Cloudflare account. The first deployment needs resources, a site address, and secrets. Once these are ready, publish updates with pnpm run deploy.
Before starting, complete Quick Start, sign in to the Cloudflare dashboard, and enable the R2 and Queues services used below.
To work through this with your AI coding tool, use this request:
Follow content/docs/deployment/cloudflare.mdx to prepare this deployment.
Use my Cloudflare account, check existing resources, and create what is missing.
Update the project name, resource settings, and live site address.
Give me exact dashboard locations when I need to do a step myself.
Keep existing settings that are still in use. After deployment, check the
homepage, docs, and features I have enabled.1. Sign in and choose your Worker name
pnpm exec wrangler loginOpen wrangler.jsonc and set the top-level name to your production Worker, such as shipstart. This file stores production settings; pnpm dev automatically uses a local URL and simulated storage.
The resource IDs and production URL belong to the original project. The following steps replace them with your own settings.
2. Create the Resources Your Site Needs
The site uses a database, file storage, a cache, and task queues. Run these commands from the project folder:
pnpm exec wrangler d1 create shipstart-db
pnpm exec wrangler r2 bucket create shipstart-media
pnpm exec wrangler kv namespace create KV
pnpm exec wrangler queues create shipstart-jobs
pnpm exec wrangler queues create shipstart-jobs-dlqThe steps below use these names throughout. If you already created the corresponding resources in your account, use their details instead of creating them again.
In wrangler.jsonc, replace:
| Section | What to set |
|---|---|
d1_databases | Set database_name to shipstart-db and use your returned ID; keep binding D1 and migrations_dir: "drizzle" |
r2_buckets | Set bucket_name to shipstart-media; keep binding R2 |
kv_namespaces | Your returned namespace ID; keep binding KV |
queues.producers | Set queue to shipstart-jobs; keep binding AI_JOBS |
queues.consumers | Set queue to shipstart-jobs and dead_letter_queue to shipstart-jobs-dlq |
In package.json, also change the database name to shipstart-db in these four commands: db:migrate:local, db:migrate:remote, db:seed:local, and db:seed:remote.
Keep the remaining rate-limit and scheduled-task settings as they are. Local users and data are not copied to the live site.
3. Initialize production data
pnpm exec wrangler d1 migrations apply shipstart-db --remoteFor media generation, also load the price catalogue:
pnpm exec wrangler d1 execute shipstart-db --remote --file=scripts/seeds/ai-prices.sqlReplace shipstart-db in these commands if you chose another database name. Check the result with the D1 guide.
4. Set the public site address
Set vars.VITE_APP_URL in wrangler.jsonc to your public HTTPS site URL and keep vars.ENVIRONMENT set to production. Production builds read the site URL from this file as well, so no duplicate .env.production URL is needed.
Other public settings, such as a captcha site key, can go in .env.production locally or in Cloudflare build variables for Git deployments. Keep VITE_ENV=development or leave it unset for full access to documentation and app pages; the current production value enables waitlist restrictions.
Remove any old CLOUDFLARE_ENV setting from Cloudflare build variables or local environment files. For Cloudflare Builds, use pnpm build as the build command and pnpm exec wrangler deploy as the deploy command, with no --env flag.
For a custom domain managed in Cloudflare, add a route at the top level of wrangler.jsonc:
{
"routes": [
{ "pattern": "app.example.com", "custom_domain": true }
]
}Replace app.example.com with your own domain, and set vars.VITE_APP_URL to https://app.example.com.
If you do not have a custom domain yet, use the workers.dev address provided by Cloudflare. Find your account subdomain under Workers & Pages. For example, a Worker named shipstart with account subdomain my-account uses https://shipstart.my-account.workers.dev. If your first deployment reports a different address, update vars.VITE_APP_URL and deploy again before testing login or payment callbacks.
5. Upload the required secrets
For login and email, upload each value to the production Worker:
pnpm exec wrangler secret put BETTER_AUTH_SECRET
pnpm exec wrangler secret put SUPER_ADMIN_EMAIL
pnpm exec wrangler secret put EMAIL_PROVIDER
pnpm exec wrangler secret put EMAIL_FROM
pnpm exec wrangler secret put RESEND_API_KEYEnter the corresponding value when prompted; EMAIL_PROVIDER is resend. Add only the keys required for your chosen AI, payment, storage, and optional OAuth setup. These private fields are read-only in the admin panel.
Local .dev.vars is for development and is not uploaded by pnpm build. Public VITE_* settings must be present at build time; changing them requires a new build.
6. Build and deploy
pnpm typecheck
pnpm run deploypnpm run deploy builds and publishes to your production Worker. Once the terminal reports success and a site address, open it in your browser. Run the same command to publish later changes to content, features, or public settings.
7. Verify the published site
- Open the published homepage,
/docs, and/zh/docs; follow the navigation to the quick start guide. - If using login, register the email in
SUPER_ADMIN_EMAIL, open the verification email, and sign in. Check/adminor/zh/admin. - Update OAuth callback URLs, payment webhooks, and storage CORS to the production hostname using their guides.
- Try the enabled AI, upload, and payment features in the appropriate test mode. Check order or task status and credits in the admin panel.
- Open
/sitemap.xmland check that its hostnames and links match your site. Use Cloudflare logs if a page or callback fails.
If a page redirects to the waitlist, check VITE_ENV, then rebuild. If authentication redirects to localhost or another domain, check wrangler.jsonc → vars.VITE_APP_URL and your OAuth callbacks.