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.
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?
Use when reviewing or setting HTTP response headers for a web app or API - security headers (Content-Security-Policy, Strict-Transport-Security, X-Frame-Options, X-Content-Type-Options, Referrer-Policy, Permissions-Policy), CORS headers, caching headers (Cache-Control, ETag, Last-Modified, Vary) and cookies (Set-Cookie flags). Also use when a security scan reports missing headers.
Master REST and GraphQL API design principles to build intuitive, scalable, and maintainable APIs that delight developers. Use when designing new APIs, reviewing API specifications, or establishing API design standards.
'Expert-level browser automation, debugging, and performance analysis using Chrome DevTools MCP. Use for interacting with web pages, capturing screenshots, analyzing network traffic, and profiling performance.'