A request blocked by CORS policy is one where the browser refused to let your script read a response from another origin, because the server’s headers did not grant your page’s origin access. The sentence after CORS policy: names the check that failed. If it mentions a preflight, fix the OPTIONS response. Otherwise fix the response to the request itself.
Everything observed below comes from test runs in November 2026: a page on one localhost port calling a Node 24 API on another, in the Chromium 159, Firefox 159 and WebKit 27.2 builds that Playwright 1.65.1 drives. Those are Playwright’s builds, not the retail browsers.
What does “blocked by CORS policy” mean?
Script on https://app.example.com cannot read a response from https://api.example.com unless that server says it may. CORS is how the server says so, with response headers that start Access-Control-. The browser does the enforcing. When a header is missing or wrong, Chromium logs this:
Access to fetch at 'http://localhost:3000/orders' from origin 'http://localhost:5174' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.
Your code sees none of that. fetch() rejects with a bare TypeError: Failed to fetch in Chromium, NetworkError when attempting to fetch resource. in Firefox, Load failed in WebKit. Each engine threw the identical error when the API was switched off, so the string in a catch block cannot tell a CORS failure from a dead server. MDN’s CORS errors page says the detail is kept from JavaScript for security reasons, which leaves the console as the place to read it.
Which response does the message refer to?
There can be two. A plain cross-origin GET, or a POST with a form or plain-text body, goes straight out, and the browser checks the headers on what comes back. Anything else is preflighted: the browser first sends an OPTIONS request asking permission, and sends the real request only if the answer passes. The main triggers on MDN’s list are a method other than GET, HEAD or POST, a Content-Type other than application/x-www-form-urlencoded, multipart/form-data or text/plain, or a header outside a short safelist. Content-Type: application/json causes a preflight. So does Authorization.
For a JSON POST with a bearer token and credentials: 'include', all three engines sent an OPTIONS carrying Origin, Access-Control-Request-Method: POST and Access-Control-Request-Headers: authorization,content-type. None attached the cookie or the Authorization header to it. Both arrived on the POST that followed.
That matters when authentication runs before CORS handling. If the auth layer answers the bare preflight with a 401, the call fails, because the Fetch standard requires a preflight response to have a status from 200 to 299.
Chromium flags a preflight failure in one of two ways: Response to preflight request doesn't pass access control check: in front of the reason, or in preflight response at the end of it. Either way, fix the OPTIONS handler.
What does each Chrome message mean?
These are the reasons Chromium 159 (the engine under Chrome) logged, each produced by breaking one thing on the test API.
| Chromium says | What to change |
|---|---|
No 'Access-Control-Allow-Origin' header is present on the requested resource. | That response has no CORS header. Check error responses, redirects and the OPTIONS route. |
The 'Access-Control-Allow-Origin' header has a value 'https://app.example.com' that is not equal to the supplied origin. | Return the calling page’s exact origin: scheme, host and port. |
contains multiple values '*, http://localhost:8801', but only one is allowed. | The header was set twice. Look for a second layer adding it, such as a proxy. |
It does not have HTTP ok status. | The OPTIONS response had the header but a status outside 200 to 299. |
Redirect is not allowed for a preflight request. | The OPTIONS request got a 3xx. Call the final URL. |
Request header field content-type is not allowed by Access-Control-Allow-Headers in preflight response. | Name the header in Access-Control-Allow-Headers. |
Method PUT is not allowed by Access-Control-Allow-Methods in preflight response. | Name the method in Access-Control-Allow-Methods. |
must not be the wildcard '*' when the request's credentials mode is 'include'. | With cookies, return the origin and not *. |
'Access-Control-Allow-Credentials' header in the response is '' which must be 'true' when the request's credentials mode is 'include'. | Add Access-Control-Allow-Credentials: true. |
The first row covers more than a server with no CORS support. A route that returned a 500 without the header produced that message word for word. Firefox and WebKit appended Status code: 500 to theirs, and the Chromium message gave no status. An OPTIONS route answering 404 with no headers got the first row too, behind the preflight prefix. A 301 without the header was blocked the same way, although the redirect’s target sent one.
For a wording that is not in the table, the strings live in one file of Chromium’s source.
Did the blocked request still reach the server?
Often, yes. A blocked GET and a blocked POST with a text/plain body both reached the handler, which ran and returned 200. The browser discarded the response. A JSON POST whose preflight failed never left the browser: the server logged the OPTIONS and nothing else. When the preflight passed and the real response lacked the header, the server logged the POST, returned 201, and the page still got a TypeError.
A CORS error is therefore no evidence that nothing happened. A user who retries after that last case sends the POST a second time.
CORS does not guard the server either. curl with a disallowed Origin header got the full 200 response from the server in the next section. To stop cross-site requests from being processed, reject them on the server, as in our post on blocking cross-site POSTs with Sec-Fetch-Site.
How do you fix it on the server?
Set the headers in one place, before routing, so every response carries them.
import { createServer } from 'node:http';
const allowed = new Set((process.env.CORS_ORIGINS ?? '').split(','));
function cors(req, res) {
const origin = req.headers.origin;
res.setHeader('Vary', 'Origin');
if (!allowed.has(origin)) return;
res.setHeader('Access-Control-Allow-Origin', origin);
res.setHeader('Access-Control-Expose-Headers', 'X-Total-Count');
if (req.method === 'OPTIONS') {
res.setHeader('Access-Control-Allow-Methods', 'GET, POST, PUT, DELETE');
res.setHeader('Access-Control-Allow-Headers', 'Content-Type, Authorization');
res.setHeader('Access-Control-Max-Age', '600');
}
}
async function handle(req, res) {
if (req.url === '/boom') throw new Error('boom');
res.writeHead(200, { 'Content-Type': 'application/json', 'X-Total-Count': '42' });
res.end('{"ok":true}');
}
createServer(async (req, res) => {
cors(req, res); // before routing, so every response carries the headers
if (req.method === 'OPTIONS') return res.writeHead(204).end();
try {
await handle(req, res);
} catch {
res.writeHead(500, { 'Content-Type': 'application/json' });
res.end('{"error":"internal"}');
}
}).listen(process.env.PORT ?? 3000);
Started with CORS_ORIGINS=http://localhost:5173 node server.mjs, this let the page read the 500 from /boom, status and body, in all three engines.
The origin is echoed from an allowlist, with Vary: Origin on every response. MDN asks for that header whenever the allowed origin is a specific one, because the response now differs by caller.
Authorization is listed by name. The Fetch standard says * in Access-Control-Allow-Headers does not cover it. All three engines still accepted the wildcard for it in this run, and Firefox logged a warning that it will stop “soon”.
Cookies need more, and MDN’s guide lists it: Access-Control-Allow-Credentials: true on both responses, credentials: 'include' in the fetch() call, and no wildcards.
Access-Control-Max-Age saves round trips. Without it, a repeat call straight away reused the preflight and one made 6.5 seconds later sent a new OPTIONS, which fits the standard’s default of 5 seconds. With 600 the later call sent none. MDN gives the caps as 2 hours in Chromium and 24 hours in Firefox.
A missing Access-Control-Expose-Headers raises no error. Without it, response.headers.get('X-Total-Count') returned null on a successful response and nothing was logged.
How do you check the headers without a browser?
Send the preflight yourself.
curl -i -X OPTIONS http://localhost:3000/orders \
-H 'Origin: http://localhost:5173' \
-H 'Access-Control-Request-Method: POST' \
-H 'Access-Control-Request-Headers: content-type'
The server above answered with this (date and connection headers trimmed):
HTTP/1.1 204 No Content
Vary: Origin
Access-Control-Allow-Origin: http://localhost:5173
Access-Control-Expose-Headers: X-Total-Count
Access-Control-Allow-Methods: GET, POST, PUT, DELETE
Access-Control-Allow-Headers: Content-Type, Authorization
Access-Control-Max-Age: 600
Then drop -X OPTIONS to see the real response, and repeat against a URL that returns an error. Keep the Origin header on each, because an allowlisting server adds nothing without it. Use the public hostname, so whatever sits in front of the app is in the path.
What we would do
If you control both sides, remove the cross-origin call. Serve the API under the page’s own origin, on a path such as /api, and no CORS check happens. In development a dev-server proxy does the same job, and our guide to Vite proxy failures covers what goes wrong there.
If the API has to live on another origin, use an allowlist like the one above, put it ahead of authentication and error handling, and curl all three responses before changing the frontend.
Do not reach for mode: 'no-cors'. In all three engines it returned an opaque response with status 0 and an empty body, which is useless to code that needs the data. Access-Control-Allow-Origin: * suits public data fetched without credentials. All three engines refused it on a credentialed request.
Whoooop builds REST and GraphQL APIs in Node.js and TypeScript, and the web apps that call them. Our API development and integration page describes that work.