How to block pre-requests made by browsers for non-simple requests?

< H1 > when the browser makes a non-simple request to the server, there will be an options pre-request. Can this be shielded? < / H1 >

now every time I enter the application, I verify the token and get a new token,. However, due to the pre-request problem, my real post request will be delayed. During this period, the token, has expired, causing the interface in the middle to hang up. Is there any solution

?

clipboard.png


  • turn off CORS if you are of the same origin. The default should be off, the xhr parameter is wrong?
  • remove unsafe request headers from different sources: https://fetch.spec.whatwg.org.
  • if you must bring the request header, set the Access-Control-Max-Age higher and cache OPTIONS in advance, then you won't need it later.

https://developer.mozilla.org.

Menu