问题
Is there any way to have one OPTIONS
request for all the subsequent POST
requests.
The application communicates with the server by means of POST
requests whenever required.There are many unrelated POST
requests happening and for each POST
request one OPTIONS
is triggered to ensure CORS
.Can we have one OPTIONS
for all these POST
requests.
回答1:
Looking here, I believe you can accomplish this by setting the "Access-Control-Max-Age" header for an arbitrarily long duration of time. This field determines how long the results from the pre-flight OPTIONS request are cached for before an additional OPTIONS request needs to be sent, so by extending it you can limit how often OPTIONS requests are sent.
来源:https://stackoverflow.com/questions/31517737/one-options-for-all-post-requests