Deploying to Production
The template deploys to Cloudflare Workers. You'll need a Cloudflare account with access to deploy Workers.
1. Configure wrangler.toml
Edit wrangler.toml to set your worker name:
toml
name = "my-app"
[env.production]
name = "my-app-prod"By default, your app will be deployed to a *.workers.dev URL. To use a custom domain, uncomment and edit the routes section:
toml
[[env.production.routes]]
pattern = "your-domain.com"
custom_domain = true2. Configure .env.production
Edit .env.production with your production settings:
bash
# Your Primitive App ID (can be the same as development or a separate production app)
VITE_APP_ID=your_production_app_id
# OAuth redirect URI for your production domain
VITE_OAUTH_REDIRECT_URI=https://my-app-prod.your-subdomain.workers.dev/oauth/callback3. Deploy
bash
pnpm cf-deploy productionThe deploy script reads .env.production, builds the project, and deploys to Cloudflare Workers.
To pass additional flags to wrangler, use -- followed by the flags:
bash
pnpm cf-deploy production -- --dry-runAdding More Environments
You can add additional environments (e.g., test, staging) by:
- Adding a section to wrangler.toml:
toml
[env.test]
name = "my-app-test"
[env.test.vars]
REFRESH_PROXY_COOKIE_MAX_AGE = "604800"
REFRESH_PROXY_COOKIE_PATH = "/proxy/"Creating a corresponding .env file (e.g.,
.env.test)Deploying:
bash
pnpm cf-deploy testThe deploy script reads from .env.{environment} and uses [env.{environment}] from wrangler.toml.