Why: The GET method is not supported for this route. Supported methods: POST.
public function dologout() {
Auth::logout();
return redirect('/showlogin');
}
Route::post('/dologout', [UserController::class, 'dologout']);
Why do I get this error: The GET method is not supported for this route. Supported methods: POST. ?
@cola
Because you are using Route::post(...). Change it to Route::get(...)
But it is not good practice to use GET for logging out.
How can I logout using Route::post(...)? What is the good practice to logging out?
Good practice is to use POST.
In your HTML
<form action="/dologout" method="post">
<input type="submit" value="Submit">
<input type="hidden" name="_token" value="{{ csrf_token() }}">
</form>
@cola Why are you even creating a logout route in the first place when Laravel has two options for authentication out of the box…?
Why do I get this error: The GET method is not supported for this route. Supported methods: POST. ?
No idea because you don't show HOW you try and access this route?
Please or to participate in this conversation.