OOmnistu

Blog / Engineering Playbooks

Engineering Playbooks

CORS explained: why your browser blocks API calls, and what not to do about it

Understand why browsers block some cross-origin API calls and why CORS is not a substitute for authentication or authorization.

OOmnistu
Reviewed 2026-11-16 · 2 min read

"Blocked by CORS policy" is a common error when a web front end calls an API on another domain. MDN's CORS guide (https://developer.mozilla.org/en-US/docs/Web/HTTP/Guides/CORS) explains the mechanism.

What it is

CORS (Cross-Origin Resource Sharing) is, per MDN, an HTTP-header based mechanism that lets a server say which origins other than its own a browser may load resources from. An origin is the combination of domain, scheme and port. For security reasons, browsers restrict cross-origin requests started by scripts: with fetch() or XMLHttpRequest, a page can only read responses from its own origin unless the other server's response includes the right CORS headers.

Example from MDN: JavaScript on https://domain-a.com calls fetch() for https://domain-b.com/data.json. The browser only exposes the response if domain-b allows it.

Two kinds of request

Cookies and credentials

By default, cross-origin fetch() calls do not send credentials such as cookies. To include them you set credentials to "include" (or withCredentials for XMLHttpRequest). MDN says the browser then rejects any response that lacks Access-Control-Allow-Credentials: true, and that for credentialed requests the server must name a specific origin in Access-Control-Allow-Origin instead of the * wildcard.

What this means in practice

Checklist for your developer

  1. Which origins call our API, and are they listed explicitly?
  2. Do we use cookies cross-origin? If so, are credentials and the allowed origin configured correctly?
  3. Do we handle the OPTIONS preflight for methods like PUT and DELETE?
  4. Do authentication and authorization checks happen on the server regardless of CORS?

The checklist is ours, based on the guide.

Limits

We did not read the sections on individual response headers (Max-Age, Expose-Headers) in detail.

By Omnistu.

Sources

Previous
Cookies for site owners: what they do and the security settings that matter