DELAPARRA
Index
Color
NL
Category: HTTP headers

Access-Control-Allow-Headers

Explained by Updated

What is Access-Control-Allow-Headers?

Access-Control-Allow-Headers: Sent in preflight responses listing which request headers are allowed cross-origin. Access-Control-Allow-Headers is part of the CORS preflight. Before a cross-origin request with custom headers, the browser sends an OPTIONS request asking whether those headers are allowed. The server answers with this header, listing the ones it accepts. A typical value is Content-Type, Authorization. If your front end sends a header that is not listed, such as X-Requested-With, the browser blocks the real request and reports a CORS error in the console.

Definition source Coders Lingo, CC BY 4.0

Frequently asked questions about Access-Control-Allow-Headers

What should you keep in mind with Access-Control-Allow-Headers?

When you see a CORS error in development, compare the headers your code sends with this list on the preflight response. The fix is almost always on the server: add the missing header to the configuration. Laravel keeps this in config/cors.php. Avoid allowing every header with * on APIs that also accept credentials.

What does an example of Access-Control-Allow-Headers look like?

Access-Control-Allow-Headers: Content-Type, Authorization

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.