繁体   English   中英

laravel 5.5-POST路线转到GET路线

[英]laravel 5.5 - POST route go to GET route

我有这条路线Route::post('/profiles', 'ProfilesController@store') ,但是它总是假设要调用函数store() 在本地服务器上一切正常。

但是,当我在生产服务器中上传所有内容时,它总是调用index() 我一点也没有收到任何错误。 我相信一些设置原因, Laravel阻断post ,挪用它get代替。

我在due component从调用路线。

我在bootstrap.js添加了csrf_token

window.axios = require('axios');

window.axios.defaults.headers.common['X-Requested-With'] = 'XMLHttpRequest';

let token = document.head.querySelector('meta[name="csrf-token"]');

if (token) {
    window.axios.defaults.headers.common['X-CSRF-TOKEN'] = token.content;
} else {
    console.error('CSRF token not found: https://laravel.com/docs/csrf#csrf-x-csrf-token');
}

在我的vue组件中:

axios.post('/profiles/', self.profile)

我想念什么吗?

即使在bootstrap.js进行了所有设置之后,我也必须显式将csrf_token添加到标头中吗?

按照要求 :)

尝试删除帖子上的斜杠:

axios.post('/profiles', self.profile)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM