Guide · Chrome, December 2026

Fix a CORS error in Chrome while testing

The Console says Access to fetch at ... has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. The request may even have reached the server. Chrome received the answer and refused to hand it to your page. This guide explains why, what the real fix is, and a stop-gap for local testing.

Why Chrome blocks it

A page at http://localhost:3000 that calls an API at https://api.example.com is making a cross-origin request. The browser lets your code read the answer only if the API's response carries a header that allows your page's origin, usually Access-Control-Allow-Origin. If it is missing, or lists another origin, you get the error.

Tools like curl and Postman don't show it because they don't enforce this rule. The rule lives in the browser, and the permission lives in the server's response.

The real fix: the API sends the headers

  • Add Access-Control-Allow-Origin with your front end's origin (or * for a public API without cookies).
  • If the request is not a simple one (it has a header like Authorization, a JSON Content-Type, or a method like PUT or DELETE), Chrome first sends an OPTIONS request, the preflight. That answer needs Access-Control-Allow-Methods and Access-Control-Allow-Headers too, and it must succeed.
  • If you send cookies or credentials, the answer needs Access-Control-Allow-Credentials: true, and the allowed origin must be a single named origin, not *.
  • Common mistake: the headers are set on the success response only, while the error response (401, 500) has none, so you see CORS instead of the real error.

If you own the API, change it there (most frameworks have a CORS setting). Nothing in the browser can replace that on a real site, because your users' browsers won't have your workaround.

Stop-gap for local testing: add the response header in your own browser

When the API belongs to someone else, or the fix is waiting for a deploy, you can add the response header in your own Chrome so you can keep building. This changes only your browser. It does not fix the API for anyone else.

Chrome's DevTools local overrides can edit response headers, but only for files you override, which doesn't suit an API you call over and over. A header extension edits the response on every matching request. With Header Switch:

  1. Install it from the Chrome Web Store. Nothing is granted at install.
  2. Open Edit profiles and create a profile, for example "Local CORS".
  3. Add a header: direction response, operation set, name Access-Control-Allow-Origin, value http://localhost:3000 (your page's origin).
  4. For a preflight, also set Access-Control-Allow-Methods and Access-Control-Allow-Headers. The free plan applies 1 profile with up to 3 headers, so this is exactly three; more headers need a paid plan.
  5. Under domains, list the API's domain (sub-domains are included), because that is where the response comes from. Click Grant access to these domains and accept Chrome's prompt. If the call is made from a page on another site, allow that site too.
  6. Reload the page. Turn the profile off, or use Pause all profiles, when you are done.

The response is changed after the server has answered, so a server that rejects the preflight with an error status can still fail. Check the Network panel: the preflight and the real request should both show the headers you set.

Other ways, and when to use them

  • A dev proxy (your bundler's proxy setting): the browser then talks to your own origin, so there is no cross-origin call. Best for a project you will keep.
  • A server-side call: have your back end call the API and your page call the back end.
  • Launching Chrome with web security off: works, but turns off protection for everything you browse in that window. We don't recommend it.

For the other Chrome tools (DevTools overrides, the user agent setting, Edit and resend) see how to change HTTP request and response headers in Chrome, or compare header extensions. Full steps are in the Header Switch documentation.

We make Header Switch. This guide was written with AI assistance. The CORS rules follow MDN's CORS documentation and the extension steps follow its documentation page; we did not test them against a live API for this guide, so check the Network panel on your own setup.