After axios sets the request header, POST becomes OPTIONS, error 405.

the first picture is before the custom headers is set. The request is correct

clipboard.png

Access-Control-Allowd-Headers/Methods/Origin

clipboard.png

and the Access-Control-Allowd-Headers/Methods/Origin set in the background is gone, so I want to know how to solve it

.
May.25,2021

OK after the backend processes the options request. Two links are recommended. If you encounter the same problem, you can take a look at
https://juejin.im/post/5a3770.
http://www.cnblogs.com/cdemo/.


405.generally speaking, it means that the method is not allowed, and the OPTIONS request is just a pre-check request for cross-domain requests. It is recommended that you check the interface.


the first options request appears because you add a custom request header, which causes your simple cross-domain request to become complex cross-domain. See if this request header is necessary, and don't use it if it's not too necessary.
secondly, the 405 method is not allowed, so it would be nice to ask the server to deal with the method, and respond normally.
you can take a look at the cors cross-domain article written by teacher Ruan Yifeng, http://www.ruanyifeng.com/blo., in which there are some introductions worth referring to.

Menu