CORS Credentials — Cookies & the Wildcard Trap

Why Access-Control-Allow-Origin: * is rejected on credentialed requests, and why Allow-Credentials plus an explicit origin must go together.

Scenario presets

Request — the browser (page) side

Method

Content-Type

Custom header

Response — headers the server sends

Access-Control-Allow-Origin

Access-Control-Allow-Methods

Access-Control-Allow-Headers

Headers the request needs + common values — click to toggle

Browser processing steps

→

Page issues a fetch request

•

Simple request (CORS-safelisted) — sent directly, no preflight

→

Actual request sent

GET /data HTTP/1.1
Origin: https://myapp.example.com
Content-Type: text/plain
Cookie: session=abc123
←

Server's actual response arrives

HTTP/1.1 200 OK
Access-Control-Allow-Origin: *
Access-Control-Allow-Credentials: true

{"status": "ok"}
✗

Wildcard '*' is not allowed for credentialed requests

✗

Browser blocks the response and rejects the fetch

Browser console

✕ Access to fetch at 'https://api.example.com/data' from origin 'https://myapp.example.com' has been blocked by CORS policy: The value of the 'Access-Control-Allow-Origin' header in the response must not be the wildcard '*' when the request's credentials mode is 'include'.

(index):1

Change any value and the steps below recompute instantly. Try the 'credentials + *' scenario to see why the wildcard fails.

With credentials: 'include', cookies and auth travel cross-origin — so the browser gets much stricter and rejects Access-Control-Allow-Origin: *. A wildcard would open your logged-in session responses to every site on the internet.

Two conditions must come as a pair: the server echoes the exact origin in ACAO and sends Access-Control-Allow-Credentials: true. Missing either fails for a different reason.

SameSite cookies add another layer — cross-site cookies need SameSite=None; Secure. Flip '*' to 'echo origin' in this simulator and watch the block lift. CORS Simulator

Frequently asked questions

Can't I keep * and just add ACAC: true?
No — with credentials the wildcard is always rejected regardless of ACAC. Reflect the request's Origin into ACAO for your allowed origins.
My cookie isn't reaching the server — why?
Beyond CORS, SameSite rules apply: cross-site cookies need SameSite=None; Secure, and third-party-cookie blocking may interfere.
How do I allow several origins? Comma-separated ACAO?
ACAO takes a single value only. Compare the request Origin against a server-side allowlist and echo back the allowed one.

Other scenarios