Deploy to Cloudflare Workers
JStack can be deployed to Cloudflare Workers, providing a globally distributed, serverless runtime for your API. This guide will walk you through the deployment process.
Prerequisites
-
Install the Wrangler CLI
Terminal
-
Make sure you have an account at Cloudflare
Deployment Steps
-
Deploy your backend to Cloudflare Workers using
wrangler deploy
. Enter the path to yourappRouter
file, by default this is:Terminal
The console output will look like this:
-
Add the deployment URL to the client:
lib/client.ts
Environment Variables
Make sure your Worker has the necessary environment variables configured. Either enter one at a time or update them in bulk:
Terminal
Production Deployment
When you deploy your front-end application:
- Deploy to your preferred hosting platform (Vercel, Netlify, etc.)
- After adding the deployment URL to your
lib/client.ts
file, your frontend will automatically connect to your Worker
Common Problems
CORS Configuration
If you are experiencing CORS problems, make sure your Worker is configured correctly:
server/index.ts