How to Proxy Supabase Through Cloudflare Workers (Step-by-Step)
Indian ISPs are DNS-blocking *.supabase.co,
breaking every app that relies on Supabase for auth, database, storage, or realtime.
In this tutorial, you will build a Cloudflare Worker reverse proxy from scratch that routes
all Supabase traffic through your own unblocked domain.
1. Why you need a Supabase proxy
If you are building with Supabase and your users are in India, your app is likely broken
right now. Multiple major ISPs - Jio, Airtel, ACT Fibernet, and others - are
DNS-blocking *.supabase.co at the network level. Every REST query, auth call, storage upload, and realtime subscription
fails with ERR_CONNECTION_TIMED_OUT.
ISP DNS blocks
Jio, Airtel, and ACT resolve *.supabase.co to sinkhole IPs via DNS poisoning. Changing to 1.1.1.1 does not help if DPI is active.
Infrastructure resilience
A proxy layer decouples your app from Supabase's domain. If blocks happen again, your users never notice.
Custom domains
Serve Supabase APIs from your own domain like api.yourapp.com. Professional branding and no third-party domain exposure.
A reverse proxy sits between your frontend and Supabase. Instead of calling xyz.supabase.co,
your client calls your-domain.com.
The proxy Worker receives the request, forwards it to Supabase, and relays the response back.
Because your-domain.com is not blocked, everything works.
2. Architecture overview
The request flow is straightforward. Your browser talks to your domain, Cloudflare's edge network runs your Worker, and the Worker talks to Supabase on the backend.
The Worker handles three types of traffic: standard HTTP requests (REST, Auth, Storage), CORS preflight requests (OPTIONS), and WebSocket upgrade requests (Realtime). Each has slightly different handling, which we will implement step by step.
3. Prerequisites
Before you start, make sure you have the following:
- A Cloudflare account (free tier works). Sign up at
dash.cloudflare.com. - A Supabase project with a project URL like
xyz.supabase.co. - Node.js 18+ installed locally.
- The Wrangler CLI installed:
npm install -g wrangler - A custom domain added to your Cloudflare account (so you can route traffic through it).
4. Step 1: Create the Worker project
Scaffold a new Cloudflare Worker project using Wrangler:
Next, configure wrangler.toml with your Supabase project URL and custom domain:
Replace xyz.supabase.co with your actual Supabase project reference
and yourapp.com with your own domain.
5. Step 2: Write the proxy handler
The core of the proxy is an HTTP handler that receives incoming requests, rewrites them to
point at your Supabase origin, forwards them, and relays the response back with proper
headers. Create src/index.ts:
Now add the handleHttp function that does the actual proxying. This is the heart of the Worker:
Key detail: Host header rewriting
You must set the Host header to Supabase's hostname.
Without this, Supabase will reject the request because the Host header would
be your custom domain, which Supabase does not recognize.
6. Step 3: Add WebSocket support
Supabase Realtime uses WebSockets. To proxy them, you need to detect WebSocket upgrade
requests, open a connection to Supabase's WebSocket server, and relay messages in both
directions using Cloudflare's WebSocketPair API.
This creates a WebSocketPair - one end (client) goes back to the browser, the other
(server) stays in the Worker. Every message from Supabase
gets relayed to the browser and vice versa. Close and error events are also forwarded to
ensure clean disconnects.
7. Step 4: Configure CORS
Browsers send a CORS preflight (OPTIONS request) before any cross-origin API call. Your proxy needs to handle these correctly or every request from your frontend will be blocked by the browser itself.
Security note: lock down origins
Avoid setting ALLOWED_ORIGINS to "*" in production.
Specify your exact frontend domains to prevent other sites from using your proxy.
You can comma-separate multiple origins in the environment variable.
8. Step 5: Deploy and configure DNS
Deploy the Worker to Cloudflare with a single command:
After deployment, configure DNS in your Cloudflare dashboard. Create a DNS record that points your subdomain to the Worker:
| Type | Name | Content | Proxy |
|---|---|---|---|
AAAA | api | 100:: | Proxied |
The AAAA record with 100:: is a Cloudflare-specific
placeholder for Worker routes - it tells Cloudflare to run your Worker for that hostname.
Make sure the orange cloud (Proxied) is enabled. Your Worker should now be live at api.yourapp.com.
9. Step 6: Update your Supabase client code
The only change in your frontend is the Supabase URL. Replace the default *.supabase.co URL with your
custom proxy domain:
That is it. The Supabase client library does not care what domain serves the API - as long as the endpoints respond with the expected Supabase format. Your anon key stays the same. All auth, database, storage, and realtime functionality works exactly as before.
Tip: use an environment variable
Store the URL in an environment variable like VITE_SUPABASE_URL or NEXT_PUBLIC_SUPABASE_URL so you can switch between
direct and proxied URLs per environment without changing code.
10. Testing the proxy
Before deploying to production, verify each layer of the proxy works.
Use these curl commands:
To test WebSocket/Realtime, open your browser DevTools and check the Network tab for ws:// connections.
You should see WebSocket frames flowing through your proxy domain.
If any test fails, check your wrangler tail logs:
11. Or just use JioBase
Building and maintaining a Supabase proxy is completely doable - but it takes time. You need to handle CORS edge cases, WebSocket reliability, rate limiting, monitoring, and keep the Worker updated as Supabase evolves its API. If you would rather skip all that and get a production-ready proxy in 60 seconds, that is exactly what JioBase does.
What you get with JioBase
- Full HTTP + WebSocket proxy
- CORS configuration dashboard
- Custom subdomains (myapp.jiobase.com)
- Real-time analytics and monitoring
- Rate limiting built-in
- Custom domain support (Pro plan)
- Cloudflare's 300+ edge locations
- Free tier: 50k requests/month
Setup is literally one line of code:
Frequently Asked Questions
Do I need a paid Cloudflare plan?
Will Supabase Auth (cookies, sessions) work through the proxy?
Can I use this with Supabase Storage file uploads?
How much latency does the proxy add?
Can I skip the manual setup and use a managed solution?
Want a quick start without Wrangler CLI?
Summary
In this tutorial, you built a complete Cloudflare Worker reverse proxy for Supabase that handles HTTP API requests, WebSocket Realtime connections, and CORS preflight. The key steps were:
- 1 Scaffold the Worker with
wranglerand configure your Supabase URL. - 2 Write the HTTP proxy handler with Host header rewriting and redirect rewriting.
- 3 Add WebSocket support using
WebSocketPairfor Supabase Realtime. - 4 Handle CORS preflight and response headers for allowed origins.
- 5 Deploy to Cloudflare and configure DNS routing for your custom domain.
- 6 Swap the Supabase URL in your client code and test.
If you prefer a managed solution that handles all of this automatically - plus analytics, rate limiting, and a dashboard - check out JioBase. Free tier includes 50,000 requests per month.
Suggested reading
More guides on Supabase, DNS blocks, and building resilient apps in India.
Supabase Blocked in India: What Happened and How to Fix It
Indian ISPs are DNS-blocking *.supabase.co. Here is everything you need to know and how to fix it.
How to Test if Your Backend is Blocked by Indian ISPs
Step-by-step diagnostic guide to check if Supabase, Firebase, or any backend is being DNS-blocked.
Fix Supabase on Jio in 60 Seconds
Ultra-short, action-focused guide. No theory, no backstory - just the fix.