Pre-flighted JavaScript requests
POST request with correct CORS setup
Summary
JavaScript code can make a cross-origin POST request.
Since there is a Content-Type header of application/json, the browser sends a pre-flight request.
The pre-flight response must include these correctly configured headers.
Access-Control-Allow-OriginAccess-Control-Allow-MethodsAccess-Control-Allow-Headers
The response to the main request must also include the Access-Control-Allow-Origin header.
Instructions
- Press F12 to open browser Developer Tools
 - Open Network tab and filter by path post-success
 - Hit green button below and observe 1 pre-flight and 1 main request
 
    View source on GitHub | Created by Tom Gregory