The Access-Control-Allow-Headers
response header is used in response to a preflight request which includes the Access-Control-Request-Headers
to indicate which HTTP headers can be used during the actual request.
The simple headers, Accept
, Accept-Language
, Content-Language
, Content-Type
(but only with a MIME type of its parsed value (ignoring parameters) of either application/x-www-form-urlencoded
, multipart/form-data
, or text/plain
), are always available and don't need to be listed by this header.
This header is required if the request has an Access-Control-Request-Headers
header.
Header type | Response header |
---|---|
Forbidden header name | no |
Access-Control-Allow-Headers: <header-name>[, <header-name>]*
<header-name>
Note that certain headers are always allowed: Accept
, Accept-Language
, Content-Language
, Content-Type
(but only with a MIME type of its parsed value (ignoring parameters) of either application/x-www-form-urlencoded
, multipart/form-data
, or text/plain
). These are called the simple headers, and you don't need to specify them explicitly.
Here's an example of what an Access-Control-Allow-Headers
header might look like. It indicates that in addition to the "simple" headers, a custom header named X-Custom-Header
is supported by CORS requests to the server.
Access-Control-Allow-Headers: X-Custom-Header
This example shows Access-Control-Allow-Headers
when it specifies support for multiple headers.
Access-Control-Allow-Headers: X-Custom-Header, Upgrade-Insecure-Requests
Let's look at an example of a preflight request involving Access-Control-Allow-Headers
.
First, the request. The preflight request is an OPTIONS
request which includes some combination of the three preflight request headers: Access-Control-Request-Method
, Access-Control-Request-Headers
, and Origin
, such as:
OPTIONS /resource/foo Access-Control-Request-Method: DELETE Access-Control-Request-Headers: origin, x-requested-with Origin: https://foo.bar.org
If the server allows CORS requests to use the DELETE
method, it responds with an Access-Control-Allow-Methods
response header, which lists DELETE
along with the other methods it supports:
HTTP/1.1 200 OK Content-Length: 0 Connection: keep-alive Access-Control-Allow-Origin: https://foo.bar.org Access-Control-Allow-Methods: POST, GET, OPTIONS, DELETE Access-Control-Max-Age: 86400
If the requested method isn't supported, the server will respond with an error.
Specification | Status | Comment |
---|---|---|
Fetch The definition of 'Access-Control-Allow-Headers' in that specification. | Living Standard | Initial definition. |
Desktop | ||||||
---|---|---|---|---|---|---|
Chrome | Edge | Firefox | Internet Explorer | Opera | Safari | |
Basic support | 4 | 12 | 3.5 | 10 | 12 | 4 |
Mobile | |||||||
---|---|---|---|---|---|---|---|
Android webview | Chrome for Android | Edge Mobile | Firefox for Android | Opera for Android | iOS Safari | Samsung Internet | |
Basic support | 2 | Yes | Yes | 4 | 12 | 3.2 | Yes |
Access-Control-Allow-Origin
Access-Control-Expose-Headers
Access-Control-Allow-Methods
Access-Control-Request-Headers
© 2005–2018 Mozilla Developer Network and individual contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Access-Control-Allow-Headers