Have gone through this issue, below is my conclusion to this issue and my solution.
According to the CORS strategy (highly recommend you read about it) You can't just force the browser to stop sending OPTIONS request if it thinks it needs to.
There are two ways you can work around it:
Access-Control-Max-Age
for the OPTIONS requestA simple cross-site request is one that meets all the following conditions:
The only allowed methods are:
Apart from the headers set automatically by the user agent (e.g. Connection, User-Agent, etc.), the only headers which are allowed to be manually set are:
The only allowed values for the Content-Type header are:
A simple request will not cause a pre-flight OPTIONS request.
You can set a Access-Control-Max-Age
for the OPTIONS request, so that it will not check the permission again until it is expired.
Access-Control-Max-Age gives the value in seconds for how long the response to the preflight request can be cached for without sending another preflight request.
Access-Control-Max-Age
is 600
which is 10 minutes, according to chrome source codeAccess-Control-Max-Age
only works for one resource every time, for example, GET
requests with same URL path but different queries will be treated as different resources. So the request to the second resource will still trigger a preflight request.