The cors-anywhere.herokuapp.com demo proxy stopped working
A request to https://cors-anywhere.herokuapp.com/ returns an error or an opt-in message instead of the proxied pageShort answer
The public cors-anywhere.herokuapp.com server is only a demo, is rate limited, and since February 2021 requires an opt-in. Do not build on it. Run your own CORS Anywhere instance and whitelist your site, or better, add the CORS headers on the API you control.
Fix it fast
1Find out which cause you have
Open the demo URL in a browser and read what it answers. It tells you whether you are blocked by the opt-in or by the rate limit.
curl -i https://cors-anywhere.herokuapp.com/https://example.com -H "Origin: https://yoursite.example"2Match what you see, then jump to its fix
What does the error look like?
A request to https://cors-anywhere.herokuapp.com/ returns an error or an opt-in message instead of the proxied pageMissing required request header. Must specify one of: origin,x-requested-with
Cause 1 of 2
The public demo is restricted and not meant for real use
1Check
The project README says the demo exists only to try CORS Anywhere, limits requests per period, and requires an opt-in as of February 2021.
curl -i https://cors-anywhere.herokuapp.com/2Fix
Stop using the demo URL. Host your own proxy, as the README recommends for any real traffic, and whitelist only your own sites.
git clone https://github.com/Rob--W/cors-anywhere.git
cd cors-anywhere
npm install
export PORT=8080
export CORSANYWHERE_WHITELIST=https://example.com,http://example.com
node server.js3Verify
Call your own instance from the page with the same Origin header.
curl -i http://localhost:8080/https://api.example.com/data -H "Origin: https://example.com"Confirmed by github.com
Cause 2 of 2
The proxy refuses requests that lack a required header
1Check
A server started with requireHeader rejects requests without those headers. Browsers send Origin on cross-origin calls, but curl does not unless you add it.
curl -i http://localhost:8080/https://api.example.com/data2Fix
Send the header your proxy requires. In a browser fetch the Origin header is added for you; for a script or test add it by hand.
curl -i http://localhost:8080/https://api.example.com/data -H "X-Requested-With: XMLHttpRequest"3Verify
The response now carries the upstream body and an Access-Control-Allow-Origin header.
curl -si http://localhost:8080/https://api.example.com/data -H "Origin: https://example.com" | grep -i access-controlConfirmed by github.com
How do I stop it coming back?
- Never ship a production app that depends on a public demo proxy.
- Whitelist your own origins on any proxy you run; an open proxy invites abuse.
- If you own the API, set the CORS headers there and drop the proxy.
Sources
How was this page made?
I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.
Which stack is behind this page?
Projects of mine built on the same technologies:
Related fixes
Web apps
The browser blocks your API response: no Access-Control-Allow-Origin header
Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at https://api.example.com/orders. (Reason: CORS header 'Access-Control-Allow-Origin' missing).
The browser received the response but refused to hand it to your script, because it did not carry an Access-Control-Allow-Origin header naming the page's origin.
4 causes, each with a fixWeb apps
Axios sends no cookie to an Express API even with withCredentials set to true
The login response has a Set-Cookie header, but the browser stores nothing
withCredentials only tells the browser to attach cookies.
4 causes, each with a fixWeb apps
The browser rejects the CORS preflight because the OPTIONS reply is not a 2xx
The request in the Network tab is an OPTIONS call with a red status, and the real GET or POST never appears
Before some cross-origin calls the browser sends an OPTIONS preflight and treats any answer outside 200 to 299 as a network error.
3 causes, each with a fixWeb apps
A public website cannot reach your local dev server: local network request blocked
Look for and connect to any device on your local network
Chrome treats a request from a public website to localhost or a private IP as a local network request.
3 causes, each with a fixWeb apps
CORS fails when you open an HTML file straight from disk
Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at file:///
A page opened from disk has an opaque origin, so browsers treat every request it makes as cross-origin, and CORS only works over http or https.
3 causes, each with a fixWeb apps
Firefox blocks a cross-origin request even though the CORS headers are set
Reason: Multiple CORS header 'Access-Control-Allow-Origin' not allowed
Firefox puts a Reason in the console message, and that text is the diagnosis.
5 causes, each with a fix