How to Fix Chrome CORS Errors

A CORS error means a web page tried to read something from a different site, and that other site’s server did not say it was allowed. Chrome blocks the read on purpose. Browsers follow a same-origin policy that stops one site from reading another site’s data; Cross-Origin Resource Sharing (CORS) is the standard way for a server to tell the browser that another origin may read its response (Google’s CORS guide on web.dev).

Whose problem is it? The server that sends the resource. It is not a Chrome fault, and it is not your network.

  • If you are just visiting the site: nothing in Chrome’s settings fixes it. Tell the site owner what is not working.
  • If you build the site: the fix is in the response headers of the server you are requesting from. The rest of this page is for you.

Find the failing request

  1. Open DevTools with F12 or Ctrl + Shift + J (Windows and Linux), or ⌘ + Option + I (Mac). See our DevTools basics.
  2. Open the Network panel and reload. Requests that failed because of CORS show CORS error in the Status column (Google’s Network panel reference).
  3. Select the request and compare the request’s Origin header with the response’s Access-Control-Allow-Origin header.

How CORS works, in three steps

From web.dev:

  1. For a cross-origin request, the browser adds an Origin header with the page’s origin (scheme, host and port).
  2. If the server wants to allow it, it adds an Access-Control-Allow-Origin header naming that origin (or * for any origin).
  3. When the browser sees a matching header, it lets the page read the response. Without one, it blocks the read and you get the CORS error.

Common causes and fixes

What you seeCauseFix on the server
No Access-Control-Allow-Origin in the responseThe server does not send CORS headers for this resourceSend Access-Control-Allow-Origin: https://app.example.com, naming the origin that needs access
The header names a different originThe allowed origin does not match the page’s scheme, host and portSend the exact origin of the requesting page
Request sends cookies and fails with *A wildcard is not allowed with credentialsName the specific origin and send Access-Control-Allow-Credentials: true
An OPTIONS request fails before the real oneThe preflight request is not answered correctlyAnswer OPTIONS with the allowed origin and Access-Control-Allow-Methods

Requests with cookies

For a request that sends cookies (for example fetch() with credentials: 'include'), web.dev says Access-Control-Allow-Origin must name a specific origin, with no wildcard, and Access-Control-Allow-Credentials must be true.

Preflight requests

Before some requests, the browser first sends an OPTIONS request, called a preflight, to ask what the server allows. According to web.dev, this happens for requests that:

  • use a method other than GET, POST or HEAD,
  • include headers other than Accept, Accept-Language or Content-Language, or
  • have a Content-Type other than application/x-www-form-urlencoded, multipart/form-data or text/plain.

The server answers the preflight with Access-Control-Allow-Origin and the methods it accepts in Access-Control-Allow-Methods. It can add Access-Control-Max-Age so the browser caches the answer and does not repeat the preflight for every request.

To find preflights in the Network panel, type method:OPTIONS in the filter box. The has-response-header filter shows only responses that carry a given header.

Why not use a CORS-unblocking extension?

An extension that switches off CORS checks only hides the error in your own browser. Your visitors still get it. While it is on, it also weakens the same-origin protection that stops other sites from reading your data. Fix the server’s headers and check the result in DevTools.

Frequently asked questions

Can I fix a CORS error in Chrome settings?

No. CORS is decided by the headers the server sends. A visitor can only report it to the site owner.

Is it safe to use Access-Control-Allow-Origin: *?

Only for public resources that any site may read. It lets every origin read the response, and it cannot be used for requests that send cookies.

Why does the same request work from the command line?

The same-origin policy is a browser rule: it is the browser that blocks a page from reading another origin’s response. A request sent from a command-line tool is not made by a web page, so there is no page origin to check.