The CORS preflight flow
Before a cross-origin request that is not “simple”, the browser sends an
automatic OPTIONS preflight asking the server which method and headers are
allowed. This reference pairs every Access-Control-Request-* header with the
Access-Control-Allow-* response the server must return, and an analyzer tells
you whether a given request preflights.
How it works
The browser preflights when the request uses a non-safelisted method or header.
The preflight is an OPTIONS carrying the intended method and headers:
OPTIONS /api/data HTTP/1.1
Origin: https://app.example
Access-Control-Request-Method: PUT
Access-Control-Request-Headers: content-type, authorization
The server must answer with matching allow headers:
Access-Control-Allow-Origin: https://app.example
Access-Control-Allow-Methods: GET, PUT, DELETE
Access-Control-Allow-Headers: content-type, authorization
Access-Control-Max-Age: 600
A request that uses only GET/HEAD/POST, safelisted headers and a safelisted
Content-Type is “simple” and skips the preflight entirely.
Tips and notes
- With credentials, never use
*— echo the exactOriginand setAllow-Credentials: true. Access-Control-Max-Agecaches the preflight; browsers cap the value.- List every custom request header in
Access-Control-Allow-Headers. Access-Control-Expose-Headerslets JS read non-safelisted response headers.