DELAPARRA
Index
Color
NL
Category: HTTP headers

Access-Control-Allow-Credentials

Explained by Updated

What is Access-Control-Allow-Credentials?

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.

Definition source Coders Lingo, CC BY 4.0

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?

Access-Control-Allow-Credentials: true

At a glance

CategoryHTTP headers
Explained by
Updated

More HTTP headers terms

All terms starting with A

Skills

Download all skills (zip)

Manuals

Related services

Need any help?

Stuck on one of these in your own project? Tell me what you are working on and I will tell you how I would approach it.