我有这个路由Route::post('/profiles', 'ProfilesController@store'),但是它总是应该调用函数store()。在本地服务器中,一切正常工作。
但是,当我上传生产服务器中的所有内容时,它总是调用index()。我一点也没搞错。我相信出于某种设置的原因,Laravel阻塞了post并将其转移到get。
我正在从due component的with呼叫这条路线。
我在我的csrf_token中添加了bootstrap.js
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)我是不是遗漏了什么?
我是否必须显式地将csrf_token添加到标头中,即使在bootstrap.js上设置了所有这些设置之后
发布于 2018-02-02 06:06:22
(应要求:)
尝试移除柱子上的尾随斜杠:
axios.post('/profiles', self.profile)https://stackoverflow.com/questions/48575358
复制相似问题