Axios always sends two requests and the first time there is an options request, how to get rid of it? I just want to have a request with token.

axios always sends two requests and the first time there is an options request, how to get rid of it?

the request header contains token

clipboard.png

Mar.24,2021

cannot be removed. The keywords simple request and non-simple request .


either do not use complex requests (such as get request)..) The complex request browser will send the pre-check command (options), which is the behavior of the browser and cannot be controlled.

I guess you are concerned that sending two HTTP requests feels a bit wasteful, so you can actually use Access-Control-Max-Age to cache the options for a certain period of time.

(to say something beside the point.. The front end is excused for not knowing HTTP , but it's a bit too much for the back end not to know the basics.)

related knowledge can be understood.


backend processing, post request will be sent twice, the first is with option, the second is post request, https://developer.mozilla.org.
part of the information, you can check this

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b389b1-e678.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b389b1-e678.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?