Simple proxy to bypass Cloudflare blocking for TheMealDB API.
macOS:
# Using Homebrew
brew install node
# Or download from https://nodejs.org/Windows:
# Download installer from https://nodejs.org/
# Or using Chocolatey
choco install nodejsLinux:
# Ubuntu/Debian
sudo apt update
sudo apt install nodejs npm
# Fedora
sudo dnf install nodejs npmVerify installation:
node --version
npm --version- Install Vercel CLI:
npm install -g vercel- Login to Vercel:
vercel login- Deploy:
vercel --prod- Your proxy will be live at a URL like:
https://your-project.vercel.app/api/proxy?s=Arrabiata
Replace:
https://www.themealdb.com/api/json/v1/1/search.php?s=Arrabiata
With:
https://your-project.vercel.app/api/proxy/search.php?s=Arrabiata
python3 local/proxy.pyThen access: http://localhost:8080/search.php?s=Arrabiata
themealdb-proxy/
├── api/
│ └── proxy.py ← DEPLOYED to Vercel (production serverless function)
├── local/
│ └── proxy.py ← NOT DEPLOYED (local testing only)
├── vercel.json ← DEPLOYED (Vercel configuration/routing)
├── .vercelignore ← Excludes local/ from deployment
└── README.md ← NOT DEPLOYED (documentation)
Deployed to Vercel:
- ✅
api/proxy.py- The actual Python code that runs in production - ✅
vercel.json- Configuration that tells Vercel how to route requests
NOT Deployed (Local Only):
- ❌
local/proxy.py- For testing on your computer before deploying - ❌
README.md- Documentation - ❌
.gitignore,.vercelignore- Configuration files
This proxy bypasses Cloudflare blocking by acting as an intermediary between your client and TheMealDB API.
School Network → Vercel Proxy → TheMealDB API
(Blocked) (Allowed) (Original API)
- Purpose: Handles incoming requests on Vercel's serverless platform
- How it works:
- Receives requests at
/api/proxy?s=Arrabiata - Adds browser-like headers (User-Agent, Referer, etc.) to mimic a real browser
- Forwards the request to TheMealDB API
- Returns the response with CORS headers enabled
- Receives requests at
- Why it works: Vercel's servers aren't blocked by Cloudflare, and the browser-like headers make the request appear legitimate
{
"rewrites": [
{ "source": "/api/(.*)", "destination": "/api/proxy" }
]
}- Purpose: Acts as a routing map - tells Vercel which code to run for which URL
- How it works:
- When someone visits
/api/proxy?s=Arrabiata - Vercel reads this config and says "run the code in
api/proxy.py" - Think of it like a phone directory: URL → Python file
- When someone visits
- Important: Both
vercel.jsonANDapi/proxy.pyget deployed and work togethervercel.json= The address book (where to route)api/proxy.py= The worker (what to execute)
- Purpose: Run the proxy locally for testing or if you prefer self-hosting
- How it works: Simple HTTP server on port 8080 that does the same thing as the Vercel function
- Use case: Testing locally before deploying, or running on your own computer
- Note: This file is NOT deployed to Vercel, it's only for local development
Cloudflare blocks requests that:
- Come from certain IP ranges (like school networks)
- Don't have proper browser headers
- Make too many requests
- Different IP: Vercel's servers have different IPs that aren't blocked
- Browser Headers: We add headers that make it look like a real browser request
- CORS Enabled: Allows your web app to call the proxy from any domain
- Serverless: No server to maintain, scales automatically
1. Your App: fetch('https://themealdb-proxy.vercel.app/api/proxy?s=Arrabiata')
2. Vercel: Receives request, runs api/proxy.py
3. Proxy: Adds headers, calls https://www.themealdb.com/api/json/v1/1/search.php?s=Arrabiata
4. TheMealDB: Returns recipe data
5. Proxy: Forwards response back to your app
6. Your App: Receives the data