CORS Preflight
PronunciationKORS PREE-flayt
Definition
A CORS Preflight is an automatic OPTIONS request sent by the browser before a cross-origin request, to check if the server allows the actual request.
Where you hear it
- In browser developer tools when debugging failed API calls - When configuring security headers on a backend server
Examples
The browser sends a CORS preflight request before making a
POSTrequest with custom headers.If the server rejects the CORS preflight, the actual API request never gets sent.
The OPTIONS preflight returned 404, so the browser never sent the POST request.
Common mistake
Thinking the preflight request carries your application data, when it only carries metadata like allowed methods and headers.
Don't confuse with
CORS preflight is often confused with CORS itself, but preflight is specifically the automatic OPTIONS check sent beforehand, while CORS is the overall security mechanism for cross-origin requests.
Say it at work
- In a meeting or chat
Let's check the browser network tab to see if the CORS preflight request is failing.
- In an email or ticket
We need to update our server configuration to handle the CORS preflight OPTIONS requests properly.