Open In App

HTTP headers | Access-Control-Allow-Credentials

The HTTP Access-Control-Allow-Credentials is a Response header. The Access-Control-Allow-Credentials header is used to tell the browsers to expose the response to front-end JavaScript code when the request’s credentials mode Request.credentials is “include”. Remember one thing when the Request.credentials is “include” mode browsers will expose the response to front-end JavaScript code if the Access-Control-Allow-Credentials is set true.

The Access-Control-Allow-Credentials header performs with the XMLHttpRequest.withCredentials property or with the credentials option in the Request() constructor of the Fetch API.



Note: Credentials are actually cookies, authorization headers or TLS(Transport Layer Security) client certificates.

Syntax:



Access-Control-Allow-Credentials: true

Directives: This header accept a single directive mentioned above and described below:

Example:

To check this Access-Control-Allow-Credentials in action go to Inspect Element -> Network check the response header for Access-Control-Allow-Credentials like below, Access-Control-Allow-Credentials is highlighted you can see.

Supported Browsers: The browsers compatible with HTTP Access-Control-Allow-Credentials header are listed below:

Article Tags :