Knowledge Base

CORS Response Headers

CORS lets browser JavaScript read selected cross-origin responses. It is a browser access policy, not authentication for an API.

Allowed origins

Access-Control-Allow-Origin: https://app.example.com
Vary: Origin

An origin consists of scheme, host, and port; the value has no path or trailing slash. Return one permitted origin, not a comma-separated list. If the returned value depends on the request's Origin, include Origin in Vary so caches distinguish responses.

Access-Control-Allow-Origin: * suits intentionally public, non-credentialed resources. Missing CORS headers are normal when external browser access is not wanted.

Credentials

To expose a credentialed response, return an explicit allowed origin and Access-Control-Allow-Credentials: true. The client also needs the appropriate credentials setting. CORS cannot override SameSite or third-party cookie restrictions.

Never blindly reflect arbitrary origins with credential access. Browser scripts on those origins could read private responses. CORS is not a replacement for authorization or CSRF defenses.

Preflight requests

Requests using methods or headers outside the CORS safelist, such as a JSON POST or an Authorization header, generally require an OPTIONS preflight. It asks permission before the actual request is sent.

Access-Control-Allow-Origin: https://app.example.com
Access-Control-Allow-Methods: GET, POST
Access-Control-Allow-Headers: Content-Type, Authorization
Access-Control-Max-Age: 600
Vary: Origin

This sample preflight permits the stated methods and request headers. Credentialed access also needs its credentials permission. Browser limits can cap preflight caching. Passing preflight does not replace the CORS headers needed on the actual response.

Reading response headers

Access-Control-Expose-Headers makes additional response headers available to browser scripts, for example X-Request-ID. It does not expose Set-Cookie, which scripts cannot read as a response header.

Some cross-origin requests can be sent even when CORS blocks reading their response. See configuration guidance and CORS error troubleshooting.

Sources

Copyright ©2026 MILAN INNOVATIONS LLC. All rights reserved.