Google chrome 如何修复Vue js中的Axios get和post请求自动更改为选项
我开发了VUEJS应用程序。我使用axios进行api调用。在chrome浏览器中,所有api调用都正常工作。但是在firefox中,一些api调用不起作用。它的方法更改为options,类型为htmlGoogle chrome 如何修复Vue js中的Axios get和post请求自动更改为选项,google-chrome,vue.js,firefox,axios,Google Chrome,Vue.js,Firefox,Axios,我开发了VUEJS应用程序。我使用axios进行api调用。在chrome浏览器中,所有api调用都正常工作。但是在firefox中,一些api调用不起作用。它的方法更改为options,类型为html this.axios .post("/login", this.userlog) .then(response => { this.successLogin(response); }) .ca
this.axios
.post("/login", this.userlog)
.then(response => {
this.successLogin(response);
})
.catch(error => {
this.errorLogin(error);
});
这是firefox中的请求头
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.13; rv:72.0) Gecko/20100101 Firefox/72.0
Accept: */*
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate
Access-Control-Request-Method: POST
Access-Control-Request-Headers: content-type
Referer: http://localhost:8080/view-request/150
Origin: http://localhost:8080
Connection: keep-alive```
如果您使用了laravel后端。你应该加上
header("Access-Control-Allow-Headers: Authorization, X-Requested-With, Content-Type, Accept");
header('Access-Control-Allow-Origin', '*');
此行位于路由文件的顶部。应使用单独的行