Laravel:POST方法返回MethodNotAllowedHttpException [英] Laravel: POST method returns MethodNotAllowedHttpException
问题描述
我的api.php
文件中有一个POST
路由,就像这样:
I have a POST
route in my api.php
file, and it is like this:
Route::group(
['namespace' => 'api'], function () {
Route::post('parent/signup', 'ParentController@signUp');
}
);
我正在尝试在postman
中访问此URL,因为这是api
路由.但是,当我向此route
发送请求时,会出现此exception
:
And I am trying to access this url in postman
as this is an api
route. But when I send request to this route
, this exception
occurs:
RouteCollection.php第218行中的MethodNotAllowedHttpException:
MethodNotAllowedHttpException in RouteCollection.php line 218:
我肯定是在发送发帖请求,如下图所示:
I am definitely sending a post request as shown in the shot below:
我跑了php artisan route:list
,这条路线是POST路线.
I ran php artisan route:list
and this route is a POST one.
| POST | api\/parent\/signup | | App\\Http\\Controllers\\api\\ParentController@signUp
我在这里做错了什么?有帮助吗?
What am I doing wrong here? Any help?
推荐答案
半个月前,我遇到了同样的问题.
I have a same problem on a half of month ago.
原因是当我在有效路线上发布时,它从http 重定向到https(由.htaccess配置),因此"POST"方法变为"GET",并且您看到MethodNotAllowedException.
The reason is when I post on valid route, it redirects from http to https (configured by .htaccess), so "POST" method becomes "GET" and you see a MethodNotAllowedException.
检查您的浏览器并按照要求进行操作,您可能会看到准确的问题.
Check your browser and follow the request, you may see the accurate problem.
这篇关于Laravel:POST方法返回MethodNotAllowedHttpException的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!