- Cloudflare account with Workers enabled
- Wrangler CLI installed:
npm install -g wrangler - Authenticated to Cloudflare:
wrangler login
The application requires the following environment secrets to be configured in Cloudflare Workers:
Used for JWT token generation and validation in authentication endpoints.
Setup:
# Generate a secure random secret
openssl rand -base64 32
# Set the secret via Wrangler CLI
wrangler secret put JWT_SECRET
# Paste the generated secret when promptedOr via Dashboard:
- Go to Cloudflare Dashboard → Workers & Pages
- Select
cc3-storefront-vite-react - Go to Settings → Variables
- Add new environment variable:
- Type: Secret
- Name:
JWT_SECRET - Value: [your secure random string, minimum 32 characters]
Comma-separated list of allowed origins for CORS requests.
Default: http://localhost:5173,http://localhost:4173 (development)
Production Setup:
wrangler secret put ALLOWED_ORIGINS
# Enter: https://yourdomain.com,https://www.yourdomain.comOr via Dashboard:
- Same steps as JWT_SECRET
- Set value to your production domains (e.g.,
https://casual-chic.com)
The application uses an R2 bucket for media storage (configured in wrangler.json):
- Bucket name:
cc3-media - Binding:
MEDIA
Setup:
# Create R2 bucket (if not exists)
wrangler r2 bucket create cc3-media-
Build the application:
npm run build
-
Test deployment (dry-run):
npm run check
-
Deploy to production:
npm run deploy
-
Verify deployment:
- Check Cloudflare Workers dashboard for successful deployment
- Test API endpoints:
https://your-worker.workers.dev/api/ - Monitor logs for any errors
Cause: Missing JWT_SECRET environment variable
Fix:
wrangler secret put JWT_SECRETCause: ALLOWED_ORIGINS not configured or incorrect
Fix:
# Set production domains
wrangler secret put ALLOWED_ORIGINS
# Enter: https://yourdomain.comCause: TypeScript compilation errors or missing dependencies
Fix:
# Clean install
rm -rf node_modules package-lock.json
npm install
# Rebuild
npm run buildFor local development with Wrangler:
-
Create
.dev.varsfile (not committed to git):JWT_SECRET=your-local-dev-secret-32-chars-min ALLOWED_ORIGINS=http://localhost:5173,http://localhost:4173
-
Run local dev server:
npm run dev
Before deploying to production:
- JWT_SECRET configured in Cloudflare Workers secrets
- ALLOWED_ORIGINS set to production domain(s)
- R2 bucket created and configured
- All tests passing:
npm test - Build successful:
npm run build - Dry-run successful:
npm run check - Monitor deployment logs for errors
For deployment issues:
- Check Cloudflare Workers dashboard logs
- Review Wrangler documentation: https://developers.cloudflare.com/workers/
- Check R2 documentation: https://developers.cloudflare.com/r2/