Access-Control-Allow-Headers
The HTTP Access-Control-Allow-Headers response header specifies which HTTP headers are permitted in a cross-origin request. Servers return this header as part of a CORS preflight response.
Usage
When a browser issues a preflight OPTIONS request, the Access-Control-Request-Headers header lists the non-safelisted headers the client intends to send. The server replies with Access-Control-Allow-Headers to confirm which of those headers are accepted.
CORS-safelisted headers are always permitted and do not need to appear in this list. The safelisted set includes Accept, Accept-Language, Content-Language, Content-Type (with restrictions on media type and value length), and Range (with restrictions on the format). Listing a safelisted header explicitly removes the extra restrictions on the value.
The value restrictions explain preflights that appear for no visible reason. A safelisted header stays safelisted only while its value is 128 bytes or shorter and free of bytes such as quotes, parentheses, colons, or angle brackets, and the combined length of all safelisted values has to stay within 1024 bytes. A long Accept or Accept-Language value set by a script therefore triggers a preflight, and the browser then expects the header name in Access-Control-Allow-Headers.
Multiple header names appear as a comma-separated list.
Directives
Header name list
A comma-separated set of header names the server accepts in the actual request.
Access-Control-Allow-Headers: Content-Type, Authorization
* (wildcard)
The asterisk acts as a wildcard for requests without credentials, permitting any header name.
Access-Control-Allow-Headers: *
Example
A preflight request asks whether Content-Type and a
custom X-Request-ID header are allowed. The server
confirms both.
Request
OPTIONS /api/data HTTP/1.1
Origin: https://app.example.re
Access-Control-Request-Method: POST
Access-Control-Request-Headers: content-type,x-request-id
The browser lowercases the requested names, sorts them, and joins them with a comma and no space. The server answers with whatever casing it prefers, since matching is case-insensitive.
Response
HTTP/1.1 204 No Content
Access-Control-Allow-Origin: https://app.example.re
Access-Control-Allow-Methods: POST
Access-Control-Allow-Headers: Content-Type, X-Request-ID
Access-Control-Max-Age: 86400
A server using the wildcard for non-credentialed requests responds with a single character.
Access-Control-Allow-Headers: *
Troubleshooting
Preflight failures related to request headers produce console errors and block the actual request.
Console shows "Request header field X is not allowed by Access-Control-Allow-Headers in preflight response." The server did not list the header name in the Access-Control-Allow-Headers value. Add the missing header to the preflight response. In nginx:
add_header Access-Control-Allow-Headers "Content-Type, Authorization";In Apache:Header set Access-Control-Allow-Headers "Content-Type, Authorization"Preflight response missing the header entirely. The server handles the OPTIONS request but does not include Access-Control-Allow-Headers in the response. Many frameworks require explicit CORS configuration for preflight routes. Check that the OPTIONS handler or middleware sets this header alongside Access-Control-Allow-Methods and Access-Control-Allow-Origin.
Wildcard
*not working with credentialed requests. When Access-Control-Allow-Credentials istrue, the wildcard is treated as the literal string*and matches nothing. List each allowed header explicitly. The Authorization header is never covered by the wildcard even for non-credentialed requests and must always be named.Server middleware rejects lowercase names. The browser always sends Access-Control-Request-Headers in lowercase, and the browser matches the server's Access-Control-Allow-Headers list case-insensitively. Trouble starts in middleware that compares its configured list, written as
Content-Type, against the incoming lowercasecontent-typewith a case-sensitive string comparison and refuses to echo the name. Normalize the configured list to lowercase or use the framework's CORS module instead of a hand-written check.Sending
Content-Type: application/jsontriggers an unexpected preflight. The Content-Type header is safelisted only for valuesapplication/x-www-form-urlencoded,multipart/form-data, andtext/plain. The valueapplication/jsonfalls outside the safelist and forces a preflight. AddContent-Typeto the Access-Control-Allow-Headers list. To confirm the preflight triggers, open DevTools Network tab and filter by method to spot the OPTIONS request preceding the actual request.
See also
- Fetch Standard: HTTP Access-Control-Allow-Headers
- CMCD
- Access-Control-Request-Headers
- Access-Control-Allow-Methods
- Access-Control-Allow-Credentials
- CORS
- HTTP headers