CORS No Access-Control-Allow-Origin Fix

This CORS error is enforced by the browser, but it is fixed on the API or proxy response, not in frontend fetch options alone.

Symptoms

  • Browser console mentions No Access-Control-Allow-Origin.
  • The same URL works in curl or Postman.
  • Requests fail only from a different domain or port.

Likely causes

  • API does not allow the frontend origin.
  • Preflight OPTIONS response is missing CORS headers.
  • Credentials are used with wildcard origins.
  • A proxy or error response drops CORS headers.

Fix steps

  1. Check the actual response headers in browser devtools.
  2. Handle OPTIONS preflight on the API or proxy.
  3. Return a specific origin when credentials are used.
  4. Make error responses include the same CORS policy.

Verify the fix

  • Test OPTIONS and real request separately.
  • Inspect Access-Control-Allow-Origin and credentials headers.
  • Confirm the failing response is not an HTML error page.

FAQ

Why does curl work?

curl is not a browser and does not enforce browser CORS rules.

Can mode no-cors fix it?

No. It creates an opaque response and usually hides the data you need.

Related tools and guides

Last updated: May 18, 2026