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
添加到 header?
根据要求:)
尝试删除 post 上的尾部斜杠:
axios.post('/profiles', self.profile)
我有这条路线 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
添加到 header?
根据要求:)
尝试删除 post 上的尾部斜杠:
axios.post('/profiles', self.profile)