HeaderDial › Guides

Fix a “blocked by CORS policy” error while testing

If your own test API is missing CORS headers, you can add them in the browser with HeaderDial, scoped to the API host. In our tests in Chrome 159 and Firefox 158, this fixed every CORS error below except one. When the server answers the OPTIONS preflight with 404 or 405, no added header helps. Then the server has to answer OPTIONS, or you call it through a dev-server proxy. Launching Chrome with --disable-web-security got past all of the errors, including the 404, because Chrome then sent no preflight at all. But it turns off these checks for every site in that window.

This page is a lookup: find the line from your console, then read its cause and fix. For the basic recipe step by step, see Add Access-Control-Allow-Origin for local testing.

Only for your own test APIs. CORS protects users: it stops other sites from reading your data with your browser. Scope the profile to the API host with a Domain filter. Never leave Access-Control-Allow-Origin: * on everywhere, and never pair it with credentials. Give the rows an expiry (the select on each row offers 15 min, 1 hour, 8 hours or 1 day) so they switch themselves off.

Find your error

The error your code catches says nothing useful. Chrome throws TypeError: Failed to fetch and logs Failed to load resource: net::ERR_FAILED. Firefox throws TypeError: NetworkError when attempting to fetch resource. The reason is in the console line just above. Chrome's line starts with Access to fetch at '…' from origin '…' has been blocked by CORS policy:. Firefox's starts with Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at …. The texts below are copied from our test runs. To match your own message to one of them, paste it into the CORS error explainer.

1. No 'Access-Control-Allow-Origin' header is present on the requested resource

Chrome: has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.

Firefox: (Reason: CORS header ‘Access-Control-Allow-Origin’ missing). Status code: 200.

Cause: a simple request (a plain GET, for example) reached the server and got an answer, but the answer has no Access-Control-Allow-Origin. The server did run the request; the browser only hides the response from your code.

Fix: a response header Access-Control-Allow-Origin: *. That alone made the GET work in both browsers.

2. Response to preflight request doesn't pass access control check

Chrome: has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource.

Firefox logs two lines: (Reason: CORS header ‘Access-Control-Allow-Origin’ missing). Status code: 200. and then (Reason: CORS request did not succeed). Status code: (null).

Cause: the request needs a preflight. It sends an Authorization or custom header, a JSON Content-Type, or uses a method such as PUT. The browser asked first with OPTIONS, and that answer had no CORS headers. The real request was never sent; our server saw only the OPTIONS.

Fix: add three response headers: Access-Control-Allow-Origin: *, Access-Control-Allow-Headers and Access-Control-Allow-Methods (see 3 and 4 for values). HeaderDial's headers are added to the OPTIONS response too. Our server answered OPTIONS with an empty 200 or 204 and no CORS headers. With the three headers added, the preflight passed and the real PUT reached the server, in both browsers.

3. Request header field authorization is not allowed by Access-Control-Allow-Headers in preflight response

Chrome: Request header field authorization is not allowed by Access-Control-Allow-Headers in preflight response. (with x-custom or another name in place of authorization for other headers)

Firefox: (Reason: header ‘authorization’ is not allowed according to header ‘Access-Control-Allow-Headers’ from CORS preflight response).

Cause: the preflight answer has Access-Control-Allow-Origin but does not allow a header your code sends.

Fix: Access-Control-Allow-Headers: Authorization, Content-Type, X-Custom, listing the headers you send. Name Authorization explicitly. * did let it through in both browsers, but Firefox logged this warning: When the `Access-Control-Allow-Headers` is `*`, the `Authorization` header is not covered. To include the `Authorization` header, it must be explicitly listed in CORS header `Access-Control-Allow-Headers`, and said the request would be blocked “soon”. Chrome logged nothing.

4. Method PUT is not allowed by Access-Control-Allow-Methods in preflight response

Chrome: Method PUT is not allowed by Access-Control-Allow-Methods in preflight response.

Firefox: (Reason: Did not find method in CORS header ‘Access-Control-Allow-Methods’).

Fix: Access-Control-Allow-Methods: GET, POST, PUT, PATCH, DELETE. Without credentials, * also worked in both browsers.

5. The value of the 'Access-Control-Allow-Origin' header in the response must not be the wildcard '*' when the request's credentials mode is 'include'

Chrome: The value of the 'Access-Control-Allow-Origin' header in the response must not be the wildcard '*' when the request's credentials mode is 'include'. If the request was preflighted, the same text comes after Response to preflight request doesn't pass access control check:.

Firefox: (Reason: Credential is not supported if the CORS header ‘Access-Control-Allow-Origin’ is ‘*’).

Cause: your code sends cookies or HTTP auth (fetch(url, { credentials: 'include' }) or xhr.withCredentials = true), and the response says *.

Fix: set the exact origin of your page and allow credentials:

Access-Control-Allow-Origin: http://localhost:3000
Access-Control-Allow-Credentials: true
Access-Control-Allow-Headers: Authorization, Content-Type, X-Custom
Access-Control-Allow-Methods: GET, POST, PUT, PATCH, DELETE

The origin is scheme, host and port, with no path or trailing slash. With credentials, list the headers and methods by name. In our test, Access-Control-Allow-Methods: * made a credentialed PUT fail with error 4 in both browsers, while the explicit list worked.

6. The value of the 'Access-Control-Allow-Credentials' header in the response is '' which must be 'true'

Chrome: The value of the 'Access-Control-Allow-Credentials' header in the response is '' which must be 'true' when the request's credentials mode is 'include'.

Firefox: (Reason: expected ‘true’ in CORS header ‘Access-Control-Allow-Credentials’).

Fix: you set the exact origin but not Access-Control-Allow-Credentials: true. Add it.

7. Response to preflight request doesn't pass access control check: It does not have HTTP ok status

Chrome: Response to preflight request doesn't pass access control check: It does not have HTTP ok status.

Firefox: (Reason: CORS preflight response did not succeed). Status code: 404. (or 405), then (Reason: CORS request did not succeed). Status code: (null).

Cause: the server answers OPTIONS with an error status, often 404 or 405 Method Not Allowed because no route handles OPTIONS. A preflight needs a success status.

Headers cannot fix this. We added all four headers from error 5 (and the * versions) to an endpoint whose OPTIONS returned 404, and another that returned 405. The preflight still failed in both browsers, and the real request never reached the server. HeaderDial changes headers, not status codes. The real fixes:

Before you blame CORS, check the OPTIONS row in the DevTools Network panel. If its status is 4xx or 5xx, this is your case.

--disable-web-security or added headers?

The usual “disable CORS in Chrome” advice is to start a second Chrome like this:

chrome --disable-web-security --user-data-dir=/path/to/empty-folder

We ran it without any extension against the same server and compared it with HeaderDial.

HeaderDial response headersChrome with --disable-web-security
Errors 1 to 6fixed, with the right headersall requests worked
Error 7 (OPTIONS returns 404/405)still blockedworked: Chrome sent no OPTIONS request at all, for any of our cases
Which sitesonly the API host in the Domain filterevery site you open in that window
Your logins, extensions, bookmarksyour normal profilea separate profile in the --user-data-dir folder; a new folder starts empty (Chromium docs)
Firefoxworks the same (all results matched Chrome)no such flag (see below)
Turning it offswitch the profile off, or let the rows expireclose that Chrome

What else the flag changes, from our runs:

Firefox has no --disable-web-security. Its about:config pref content.cors.disable does the opposite of what the name suggests. With it set to true, every cross-origin fetch() in our test failed with (Reason: CORS disabled)., including the plain GET.

Steps in HeaderDial

  1. Click the HeaderDial icon. If the site access banner shows, allow access. The page and the API are usually on different hosts, and Chrome only changed the response when HeaderDial had access to both (tested here). Choose Allow on all sites, or Only <host> once on a page tab and once on an API tab.
  2. Click + Response header and add the headers your error needs, from the list above. Leave the op select on set, so it replaces any value the server already sends.
  3. Open Where it applies, click + Only on…, choose Domain and enter the API host, for example localhost or api.dev.example.com.
  4. Set the expiry select on each row, for example 1 hour.
  5. Reload your app and check that the console line is gone and the Network panel shows the real request after the OPTIONS one.

Shortcut (HeaderDial 0.7.0): open the popup on your app's tab and pick + Recipe… → CORS: allow calls from this page's origin. It adds Access-Control-Allow-Origin set to that tab's origin, Access-Control-Allow-Credentials: true, the usual methods, and Authorization, Content-Type as allowed headers. Add any other custom header names to that row, then do steps 3 and 4.

Things to know

What we measured

A local Node server reachable as http://127.0.0.1:PORT (the page) and http://localhost:PORT (the API), which are different origins. The API sent no CORS headers and answered OPTIONS with an empty 200, 204, 404 or 405, depending on the endpoint. The server logged every request, so we could see whether a preflight or the real request arrived. HeaderDial 0.6.0, host access granted to all sites, one profile limited to Domain localhost. Chrome for Testing 159.0.8154.6 and Firefox 158.0.1, both headless on Linux, 20 November 2026. The flag column is Chrome with --disable-web-security and a new --user-data-dir, no extension.

Request from the page to the APIChrome 159 + HeaderDialFirefox 158 + HeaderDialChrome, flag
Plain GET, nothing addedblocked (error 1)blocked (error 1)works
Plain GET, Allow-Origin: *worksworks–
credentials: 'include', Allow-Origin: *blocked (error 5)blocked (error 5)works
credentials: 'include', exact origin + Allow-Credentials: trueworksworks–
PUT JSON or custom header, OPTIONS 200/204, only Allow-Origin: *blocked (errors 3, 4)blocked (errors 3, 4)works, no preflight sent
Same, with Allow-Origin, Allow-Headers, Allow-Methodsworksworks–
Authorization from the page, Allow-Headers: *works, no warningworks, with a warningworks
Credentialed PUT, exact origin + Allow-Credentials: true, Allow-Methods: *blocked (error 4)blocked (error 4)works
PUT JSON, OPTIONS 404 or 405, all headers addedblocked (error 7)blocked (error 7)works, no preflight sent
HeaderDial adds Authorization to a plain GETno preflight; token arrivesno preflight; token arrives–
Read the DOM of a cross-site iframe––blocked; readable with --disable-site-isolation-trials

Add to ChromeFirefox: coming soon