ASP.NET Core Web API Interview Question #142

What is a CORS preflight request?

Error Handling, Logging, Caching, Rate Limiting, CORS & Reliability Senior Advanced

Quick Interview Answer

For certain cross-origin requests, a browser first sends an OPTIONS request to ask whether the actual method, headers, and origin are permitted. This is called a preflight request.

Detailed Explanation

For certain cross-origin requests, a browser first sends an OPTIONS request to ask whether the actual method, headers, and origin are permitted. This is called a preflight request.

The CORS middleware responds according to the configured policy. Developers normally should not create separate business actions just to manually process standard preflight behavior.

Code Example

OPTIONS /api/orders
Origin: https://app.example.com
Access-Control-Request-Method: POST
Access-Control-Request-Headers: authorization,content-type