Building it

What a CORS Error Actually Is (and Who Has to Fix It)

A CORS error is the browser refusing to hand your code a response the server never permitted it to read. What the message means, and who owns the fix.

Illustration: a browser window holding back a response from a server behind a barrier

The short answer

A CORS error is not your request failing. It is the browser refusing to let your JavaScript read a response, because the server that sent that response never said your origin was allowed to read it.

Two sentences carry the whole subject:

  • The server declares the policy, in response headers whose names begin with Access-Control-.
  • The browser enforces it, on the user's behalf, and tells your code nothing about why.

That split is the reason the error shows up in a browser console while the fix almost always belongs on a server. You can read any endpoint's declaration for yourself with our free CORS Checker: it sends a request from an origin you choose and shows the exact answer a browser would get.

Flow diagram from your page to the server to the browser, with allowed and blocked outcomes
The policy travels back with the response. Your page sends the request and has no further say in what happens to the answer.

What the message actually says

The wording differs by browser, which is half the reason the same problem gets searched a dozen ways.

Chrome and other Chromium browsers assemble a sentence from fixed pieces in the source:

Text
Access to fetch at 'https://api.example.com/data' from origin 'https://app.example.com'
has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on
the requested resource.

Firefox writes one sentence and puts the diagnosis in a parenthesis at the end:

Text
Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote
resource at https://api.example.com/data. (Reason: CORS header
'Access-Control-Allow-Origin' missing).

Both are saying the same thing. The part worth reading is the tail: the specific reason. MDN keeps one page per Firefox reason, which helps only once you know which reason you have, so here are the common ones from both browsers side by side.

Chrome saysFirefox reasonWhat it meansFix belongs to
No Access-Control-Allow-Origin header is presentAccess-Control-Allow-Origin missingThe server sent no policy at allThe API owner
The header has a value that is not equal to the supplied originAccess-Control-Allow-Origin does not matchA policy exists, and your origin is not in itThe API owner
The header must not be the wildcard when the credentials mode is includeCredential is not supported if the header is *Cookies plus a wildcard is forbiddenThe API owner
Response to preflight request does not pass access control check: it does not have HTTP ok statusCORS preflight channel did not succeedNobody answered the OPTIONS request properlyThe API owner
Method is not allowed by Access-Control-Allow-MethodsDid not find method in Access-Control-Allow-MethodsPreflight was answered, but not for that methodThe API owner
Request header field is not allowed by Access-Control-Allow-Headersmissing token in Access-Control-Allow-HeadersPreflight was answered, but not for that headerThe API owner
The header contains multiple values, but only one is allowedMultiple Access-Control-Allow-Origin not allowedTwo layers each added the headerWhoever owns the second layer
Cross origin requests are only supported for protocol schemesCORS request not httpThe page or URL is file:// or similarYou, on the client

Note what the table does not contain: a line you can put in your frontend. MDN is blunt about it: most CORS errors can only be resolved on the server, because the server controls whether cross-origin access is allowed.

Your code cannot see any of this

The detail in those messages reaches the console and stops there. The specifics of a CORS failure are deliberately withheld from JavaScript, so a fetch() rejects with a generic TypeError and your catch block learns only that something failed. That is not a gap in the API. If scripts could read the reason, a malicious page could use the error channel itself to probe which internal hosts exist and what they allow.

The practical consequence: a CORS problem cannot be diagnosed from your own error handler or your error-tracking dashboard. You need the console, or a tool that sits outside the browser and reads the headers directly.

The request was not blocked. The response was.

This is the single most useful correction to make, because it decides whether the thing you just tried actually happened.

For a simple request, the browser sends it. The server receives it, runs it, and answers. Only then does the browser compare the policy against your origin and, finding no permission, refuse to hand the response to your code. A POST that creates a record created the record. You simply never got to read the receipt.

For a preflighted request, the order is different. The browser asks permission first with an OPTIONS request, and if that permission does not come back, the real request never leaves the browser at all. Nothing happened on the server.

So "did my request go through?" has two answers, and which one applies depends entirely on whether a preflight was involved.

What counts as a different origin

An origin is three things joined together: the scheme, the host and the port. Change any one of them and you are cross-origin, however similar the two addresses look.

Your pageYour requestSame origin?
https://app.example.comhttps://app.example.com/api/v1/ordersYes, only the path differs
http://localhost:3000http://localhost:8000/apiNo, the port differs
https://example.comhttp://example.com/apiNo, the scheme differs
https://www.example.comhttps://api.example.comNo, the host differs
https://example.comhttps://example.com:8443/apiNo, the port differs

The second row is why a local development setup hits this before anything is deployed. A React dev server on port 3000 calling an API on port 8000 is a genuine cross-origin request, and the browser treats it exactly as it would treat a request to a stranger's domain. A subdomain is not a shortcut either: the fourth row is cross-origin, and so is the reverse direction.

A URL split into scheme, host and port, with four same-origin comparisons
The path is not part of the origin, which is why a dev server on port 3000 calling port 8000 is as cross-origin as a stranger's domain.

The preflight: a second request you did not write

Most people meet the preflight without ever having asked for one. The browser sends an OPTIONS request ahead of the real one, and waits.

It does this when the request stops qualifying as simple. A request is simple only when all of the following hold:

  • The method is GET, HEAD or POST.
  • Every header you set is on the CORS-safelisted list, such as Accept, Accept-Language, Content-Language and Content-Type.
  • The Content-Type, if present, is one of application/x-www-form-urlencoded, multipart/form-data or text/plain.

Read that third line again, because it catches almost everyone. Content-Type: application/json is not on the list. A plain JSON POST, the most ordinary request in modern web development, triggers a preflight. So does an Authorization header, and so does any PUT or DELETE.

This is what sits behind one of the most common bug reports in this area: it worked, then a token was added for authentication, and it stopped working. Nothing about the data changed. Adding that one header converted a simple request into a preflighted one, and the server that happily answered GET had no handler for OPTIONS.

The server has to answer the preflight with an ok status and with Access-Control-Allow-Methods and Access-Control-Allow-Headers that cover what the real request is about to use. Two further details are worth knowing: Access-Control-Max-Age lets the browser cache that permission for a number of seconds instead of asking before every call, and a preflight never carries credentials, so cookies and Authorization are absent from the OPTIONS request even when the real request will include them. An OPTIONS route sitting behind your authentication middleware will therefore be rejected before it can answer.

Two sequence diagrams comparing a simple request with a preflighted OPTIONS request
The difference decides whether the work already happened. A blocked simple request has already run on the server; a failed preflight stops the real request leaving the browser.

Why it works in curl and Postman

Because CORS is a rule browsers follow, not a rule servers enforce.

curl has no origin. It is not running a page on anyone's behalf and has no cookie jar belonging to a logged-in user, so there is nothing for the policy to protect. The same is true of Postman, of your backend calling the same API, and of any script. All of them get the response.

This makes curl a poor test. A successful curl tells you the endpoint is reachable and says nothing whatsoever about whether a browser will let your page read it. What you need is a request that carries an Origin header and a look at what comes back, which is precisely what the CORS Checker does.

Read the policy yourself

Three runs on the live checker, all on 26 November 2026:

EndpointTest originAccess-Control-Allow-OriginVerdict
api.github.com/users/octocathttps://example.org*Allowed, by wildcard
www.bitssolved.com/https://example.orgabsentBlocked
httpbin.org/response-headers?...https://myapp.examplehttps://allowed.example.comBlocked, mismatch

The first row is a public API doing the right thing: no credentials, no secrets, open to everyone. The second is this site's own home page, which is an ordinary web page and has no reason to be readable by other people's scripts. The third was constructed on purpose, using an endpoint that echoes back whatever header you ask it to, so the result shows what a near miss looks like: a policy that exists, names one origin and does not name yours.

That middle row is worth dwelling on, because an absent header is not a misconfiguration. It is the default, and for the vast majority of pages on the web it is the correct setting. CORS headers are an opt-in, added deliberately to endpoints meant to be called from other origins.

Who has to fix it

Everything above reduces to one question with three answers.

You control the server. Then it is yours, and it is a small change: return Access-Control-Allow-Origin with your frontend's exact origin, and answer OPTIONS if the request is preflighted. The specifics differ by stack, and that is the subject of the next post in this series.

You do not control the server. Then you cannot fix it in the browser, and no amount of frontend code will help. Two routes remain. Many hosted APIs have a dashboard where you register the origins allowed to call them, and the fix is a form field rather than a code change, so look there first. Failing that, call the API from a server you do control and pass the result to your page. MDN lists that proxy route explicitly: your server fetches the resource on your behalf and returns it with headers you choose. It adds a hop of latency and something new to maintain, and it is the honest answer when the other side will not change.

The request carries cookies or a session. Then the rules tighten, and a wildcard becomes illegal rather than merely loose. The server has to echo one specific validated origin, send Access-Control-Allow-Credentials: true, and add Origin to its Vary header so that caches do not serve one origin's permission to another. That last header is quietly important and easy to forget, and our checker reports it alongside the others.

Four things that look like fixes and are not

A browser extension that turns the policy off. It works, on your machine, for you. Every real visitor still fails, and you have hidden the only signal that would have told you so.

Launching Chrome with web security disabled. Same outcome, with an extra cost: the protection is now off for every other site in that browser session, not just yours.

Switching the request to mode: "no-cors". The request goes out, but the response becomes opaque: status 0, empty headers, a body your code cannot read. That is genuinely useful for a fire-and-forget beacon or a service worker warming a cache, and useless when you actually wanted the data.

Putting Access-Control-Allow-Origin: * on everything. It is the right answer for a public, credential-free endpoint and the wrong one everywhere else. On an endpoint that returns anything user-specific, a wildcard invites any page on the web to read it with your visitor's browser. The browser blocks the combination with cookies outright, which saves you from the worst version, but it does not save you from exposing data that needs no cookie to fetch. Our security headers checklist covers where this sits among the other headers worth auditing, and the security headers checker reads them all in one pass.

Frequently asked questions

What is the full form of CORS?

Cross-Origin Resource Sharing. It is the standard that lets a server relax the same-origin policy for chosen origins. The policy is the restriction; CORS is the opt-out mechanism.

What status code is a CORS error?

It does not have one. A CORS error is a browser decision made after the response arrives, so the response can be a perfectly healthy 200 and still be withheld from your code. If you are looking at a 403 or a 500, you are looking at a different problem. Our checker shows the response status next to the headers for exactly this reason, and the HTTP header checker gives you the full response if you need more.

Can I fix a CORS error with frontend code?

Only by changing the question. You can stop needing the response, with no-cors. You can stop the request being cross-origin, by routing it through your own origin. You cannot talk the browser out of enforcing a policy the server did not grant.

Why did it work yesterday and not today?

Something moved one of the three origin parts, or the policy itself. Common causes: a move from http to https, a new domain or preview URL that nobody added to the allowlist, an Authorization header added to the request that started a preflight, a CDN or reverse proxy that now strips or duplicates response headers, or an API provider tightening a previously open endpoint.

Does CORS protect my API?

No, and treating it as protection is a real mistake. CORS protects a user's browser session from other websites. It does nothing about curl, a script, a mobile app or another server, all of which ignore it entirely. Authentication, authorisation and rate limiting are separate jobs and none of them is done by an Access-Control- header.

Why can my page show a cross-origin image but not read it?

Because embedding and reading are different permissions. An <img> tag displays a cross-origin image without any CORS involvement, but the moment you draw it to a canvas and try to read the pixels back, the canvas is tainted and the read fails. The same split explains why web fonts loaded with @font-face need CORS while a stylesheet link usually does not.

Is a CORS error the same as a mixed content error?

No. Mixed content is an HTTPS page loading an http:// resource, and the browser blocks or upgrades it over the scheme alone. CORS is about permission to read across origins. They can appear together, since a scheme change also changes the origin, but they are separate checks with separate messages.

The takeaway

Read the end of the error message, not the beginning. The beginning tells you it is a CORS problem, which you already knew. The end names the reason, and the reason names the owner.

If the response carries no Access-Control-Allow-Origin at all, or names an origin that is not yours, the fix is a server change and the only question is whose server. If the message mentions a preflight, the OPTIONS request is the thing to look at, not the request you wrote. And if it mentions credentials and a wildcard together, the server is asking for something the standard forbids.

Start by reading the policy as a browser sees it, with the CORS Checker. That takes the guesswork out of the first question, which is whether the header is missing, wrong or simply not meant for you.

If an integration like this is holding up a build, our web development service takes on API and frontend work of exactly this kind. For a one-off header problem, the free tools above will usually settle it faster.

Tools mentioned in this post