preflight request
An automatic OPTIONS request a browser sends before a cross-origin request that is not simple, to ask the server for permission first.
In more detail
It names the origin, the intended method in Access-Control-Request-Method, and any extra headers. The server answers with the methods and headers it allows and how long the browser may remember the decision, and with Vary: Origin so caches keep answers per origin.
Example
In the browser: It is triggered by non-simple requests, such as methods like PUT or DELETE, custom headers, or a JSON content type. The server answers with Access-Control-Allow-Methods and Access-Control-Allow-Headers, and only then does the browser send the real request.Related terms
- OPTIONS — The HTTP method that asks a server which communication options a resource supports, used by browsers for CORS preflight requests.
- CORS — The browser rule set that decides whether web page code from one origin may read a response from a different origin.
- CORS headers — The Access-Control response headers a server uses to tell browsers which origins, methods and headers may be used across origins, and for how long.
- simple request — A cross-origin request that browsers send without a preflight because it uses only basic methods and headers, such as a plain GET.
Taught in
- Cookies And CORS — Modern API Architecture: REST, GraphQL & gRPC
- Same-Origin Policy, CORS Preflight, Credentials And Headers — Frontend Architecture & Web Platform