This Cloudflare Worker acts as a proxy for Browserless.io API calls, adding the necessary CORS headers to allow browser-side requests.
Browserless.io's API doesn't include CORS headers, so it can't be called directly from a browser. This worker proxies the request and adds the appropriate headers.
-
Create a Cloudflare account (if you don't have one)
- Go to https://workers.cloudflare.com/
- Sign up for free
-
Create a new Worker
- Click "Create a Worker"
- Replace the default code with the contents of
worker.js - Click "Save and Deploy"
-
Copy your Worker URL
- It will look like:
https://battlecard-proxy.your-subdomain.workers.dev
- It will look like:
-
Add to your .env.local
VITE_BROWSERLESS_PROXY_URL=https://battlecard-proxy.your-subdomain.workers.dev -
Restart the dev server
npm run dev
Cloudflare Workers free tier includes:
- 100,000 requests/day
- 10ms CPU time per request
This is more than enough for Intel Deck usage.
The worker expects the Browserless token to be passed in the request body (not stored in the worker), so your token stays in your local environment.