My laravel version is 9.19. When I click on logout menu its working fine.
But when I manually type ‘logout’ in url it gives the error – The GET method is not supported for route logout. Supported methods: POST.
It shows as a POST route in route:list:
POST logout .............. logout › Auth\LoginController@logout
in web.php:
Auth::routes( [ 'register' => false ] );
How can i solve this in case of manually type ‘logout’ in url?
it isn’t a
GET
route, it is aPOST
route … there is no reason to type in a URL to logout and it shouldn’t be a simple link, causing aGET
request … there is good reason for this being aPOST
routeEither use logout as POST request OR do
Route::get(...logout class here@method)
in your auth.php or wherever your logout route is located.Though it is better to use POST request for logout as per what @lagbox said!
having said all of that, if you really wanted to you could create a
GET
route that points to that same action on that controller as stated by Mr.Kenneth, just don’t put it into production with that route existingWhy would you, or anyone, manually type the URL?