Access-Control-Allow-Credentials: Whether the response may be exposed to JS when the request was made with credentials (cookies, Authorization). Access-Control-Allow-Credentials: true tells the browser that a cross-origin response may be read by JavaScript even when the request included cookies or an Authorization header. You need it when a front end on one domain calls an API on another and relies on a login session, for example app.example.com calling api.example.com with credentials: 'include'. Without the header, the browser sends the request but hides the response from your code.
Frequently asked questions about Access-Control-Allow-Credentials
What should you keep in mind with Access-Control-Allow-Credentials?
There is one firm rule. When credentials are allowed, Access-Control-Allow-Origin cannot be *. It must name the exact origin. This protects users, because otherwise any website could make logged-in requests on their behalf and read the answers. Keep the list of allowed origins short and explicit, and never copy the request's Origin header back without checking it against that list.
What does an example of Access-Control-Allow-Credentials look like?
Use when reviewing or setting HTTP response headers for a web app or API - security headers (Content-Security-Policy, Strict-Transport-Security, X-Frame-Options, X-Content-Type-Options, Referrer-Policy, Permissions-Policy), CORS headers, caching headers (Cache-Control, ETag, Last-Modified, Vary) and cookies (Set-Cookie flags). Also use when a security scan reports missing headers.
Master REST and GraphQL API design principles to build intuitive, scalable, and maintainable APIs that delight developers. Use when designing new APIs, reviewing API specifications, or establishing API design standards.
'Expert-level browser automation, debugging, and performance analysis using Chrome DevTools MCP. Use for interacting with web pages, capturing screenshots, analyzing network traffic, and profiling performance.'