Reputation: 8937
If I have foreknowledge that CORS calls made with Angular will, indeed, work, can I suppress the OPTIONS calls so that they don't continue needlessly occurring in production?
Upvotes: 0
Views: 472
Reputation: 33578
To avoid the OPTIONS
request you need to make sure that your request is a "simple" request.
A simple cross-site request is one that:
Only uses
GET
,HEAD
orPOST
. IfPOST
is used to send data to the server, theContent-Type
of the data sent to the server with the HTTPPOST
request is one ofapplication/x-www-form-urlencoded
,multipart/form-data
, ortext/plain
.Does not set custom headers with the HTTP Request (such as
X-Modified
, etc.)
Check that Angular isn't setting x-requested-with
or anything else unexpected.
Upvotes: 0
Reputation: 11568
This OPTIONS request tells the client if a CORS request will be allowed; and, for those requests, which methods (GET, POST, PUT, etc.) can be executed.
According to W3c options call is not required if you are implementing only simple methods: GET/POST/HEAD.
So where you set your Access-Control-Allow-Methods if it is * try changing it to "GET,POST" and based on the standard (if the browser follows), your browser doesn't need to fire the options call.
Upvotes: 1