Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4072 pages
Next.js and React

The cors-anywhere.herokuapp.com demo proxy stopped working

ErrorA request to https://cors-anywhere.herokuapp.com/ returns an error or an opt-in message instead of the proxied page

Short 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.

  • Applies to Node.js 22, cors-anywhere 0.4
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Fix it fast

  1. 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"
  2. 2Match what you see, then jump to its fix

    1. 1An error status, or a message about requesting temporary access to the demoThe public demo is restricted and not meant for real useFix
    2. 2Missing required request header. Must specify one of: origin,x-requested-withThe proxy refuses requests that lack a required headerFix

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 page
  • Missing 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.js

3Verify

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

Did this fix it?

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/data

2Fix

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-control

Confirmed by github.com

Did this fix it?

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 fix

Web 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 fix

Next step

Want this handled for good?

I look after servers, apps and releases end to end. Tell me what keeps breaking.