Q42: How do CORS preflight OPTIONS requests interact with custom Authorization headers?

Difficulty:MediumTopic:Browser Security

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 OPTIONS preflight requests with 200 OK or 204 No Content.
  • The response must include header Access-Control-Allow-Headers: Authorization, Content-Type.
  • Preflight OPTIONS requests do NOT carry Bearer tokens; API Gateway security filters must explicitly bypass token validation for OPTIONS calls.
Key Takeaways
  • CORS OPTIONS preflight checks carry no authorization headers.

  • APIs must allow unauthenticated preflight OPTIONS requests to return allowed CORS headers.