【发布时间】:2020-07-25 09:05:54
【问题描述】:
我正在尝试创建一个表单,用户在其中填写一些数据,然后将数据提交到服务器
methods: {
sendOrder () {
this.loading = true;
axios.post ('/send/', {
firstName: this.firstName,
lastName: this.lastName,
phone: this.phone,
delivery: this.delivery,
... (this.delivery? {address: this.address}: {}),
note: this.note,
items: this.items,
total: this.total
})
这在我的本地服务器上效果很好,但是当我在真实服务器上设置时,我在控制台中收到以下错误:
http://my-website.com/email-sender/public/send 405 (Method Not Allowed)
我怀疑你可以看到的这部分回复...email-sender/public...
这可能是由于错误的 .htaccess 设置吗?
另外,当我通过邮递员向同一路线发出发布请求时,我收到此错误:
Status: 419 unknown status
我将请求发送到http://my-webiste.com/send 或
http://my-webiste.com/public/email-sender/send邮递员的错误总是419。
路线(来自评论):
Route::get('/', 'OrderController@index');
Route::get('/thankyou', 'OrderController@thankyou');
Route::post('/send', 'OrderController@send');
【问题讨论】:
-
请显示您的路线。
-
Route::get('/', 'OrderController@index'); Route::get('/thankyou', 'OrderController@thankyou'); Route::post('/send', 'OrderController@send');
-
/send/和/send可能是不同的网址。此外,Laravel 中的public文件夹应该是您的项目/服务器的“DocumentRoot”,并且不会出现在您的网址中 -
我在 axios 方法和
web.php中都将路由更改为/send,但仍然出现相同的错误。我不知道为什么项目根目录出现在 url 中。