Cloudflare Workers run at the edge, providing low-latency proxying with minimal configuration. This is the recommended approach if you already use Cloudflare for DNS.
Prerequisites
- A Cloudflare account
- A domain managed by Cloudflare (or external DNS pointing to Cloudflare)
- Access to create Workers in your Cloudflare dashboard
Setup Guide
Create a new Worker
- Log in to your Cloudflare dashboard
- Navigate to Workers & Pages in the sidebar
- Click Create application → Create Worker
- Give your worker a name (e.g.,
analytics-proxy) - Click Deploy to create the initial worker
Add a route to your domain
- Go to your Worker’s Settings → Domains & Routes
- Click Add → Route
- Enter the route pattern:
yourdomain.com/analytics/* - Select your zone
- Click Add route
Test Your Worker
Before configuring your SDK, verify the Worker is routing requests correctly:-
Open your browser and navigate to:
- You should see a response from the Composite API (or a valid error response, not a Cloudflare error page)
-
Check the Network tab in DevTools to confirm:
- The request reaches your Worker
- The response headers include your CORS headers
- No redirect loops occur
Resolve DNS Conflicts
If your Worker route isn’t handling requests, you may have conflicting DNS records.Check for existing records
- Go to your Cloudflare dashboard → DNS → Records
- Look for any A, AAAA, or CNAME records for your root domain or the path you’re using
Delete or disable conflicting records
If you have existing records that might intercept traffic before it reaches your Worker:
- Delete the conflicting record, or
- Disable the Proxy toggle (orange cloud → grey cloud) to let the Worker handle routing
DNS changes typically propagate within minutes, but can take up to 48 hours in rare cases.
Troubleshooting
Worker returns 404 for all requests
Worker returns 404 for all requests
Ensure your route pattern matches your URL structure:
yourdomain.com/analytics/*Check the Worker is deployed and the route is active in Workers & Pages → Your Worker → Settings → Domains & Routes.CORS errors in browser console
CORS errors in browser console
Verify the Worker includes the CORS headers in the response. The example code above handles this, but if you’ve customized it, ensure
Access-Control-Allow-Origin is set.For Chrome extensions, you may also need to add your extension’s origin to the allow list.Requests timing out
Requests timing out
Check Cloudflare’s dashboard for Worker errors:
- Go to Workers & Pages → Your Worker → Logs
- Look for any exceptions or failed requests
prod.alb.us.api.composite.com is accessible from Cloudflare’s network.