Q42: How do CORS preflight OPTIONS requests interact with custom Authorization headers?
When client-side web applications attach custom HTTP headers (such as Authorization: Bearer <token>) to cross-origin API requests, browser specifications require issuing an automated CORS Preflight request (OPTIONS) before sending the actual HTTP request.
Critical API Rules:
- The API server must respond to
OPTIONSpreflight requests with200 OKor204 No Content. - The response must include header
Access-Control-Allow-Headers: Authorization, Content-Type. - Preflight
OPTIONSrequests do NOT carry Bearer tokens; API Gateway security filters must explicitly bypass token validation forOPTIONScalls.
Key Takeaways
CORS OPTIONS preflight checks carry no authorization headers.
APIs must allow unauthenticated preflight OPTIONS requests to return allowed CORS headers.