i made a post route in laravel but when access it i find that get request was sent
this is error SymfonyComponentHttpKernelExceptionMethodNotAllowedHttpException: The GET method is not supported for route api/login. Supported methods: POST
i made a post route in laravel but when access it i find that get request was sent
this is error SymfonyComponentHttpKernelExceptionMethodNotAllowedHttpException: The GET method is not supported for route api/login. Supported methods: POST
3
Answers
If you wan’t to acces to the route with a normal view (GET method) you need to change your code with
Route::get
in your writed code way you only accept POST methodRoute::post
set olso the accept inapplication/json
otherwise in postman you will see an html filePut your login/register route outside of middleware group.
This happens primarily because of validation issues of API as the Laravel validator sends back to the same URL, Like in this case, it is redirecting back to the login route by the GET method so it’s saying you method not allowed.
For this issue, you need to change Postman settings where you need to uncheck Automatically follow redirects to off.