I made a laravel system and included the Auth scaffolding stated in the documentation. I installed it by using
composer require laravel/ui --dev php artisan ui vue --auth
And running npm install
and npm run dev
to compile the assets. But for some weird reason the /logout
route returns a 404. My routes look like this
Route::get('/', function () { return view('welcome'); }); Auth::routes();
I don’t know where to look. How can I fix this?
Advertisement
Answer
If you take a look at vendor/laravel/framework/src/Illuminate/Routing/Router.php
you will see this piece of code:
public function auth(array $options = []) { // Authentication Routes... $this->get('login', 'AuthLoginController@showLoginForm')->name('login'); $this->post('login', 'AuthLoginController@login'); $this->post('logout', 'AuthLoginController@logout')->name('logout'); ...
Which means that no GET
route is defined for logout, only POST
.
That’s why you are getting a 404 response.
You can add one GET
route by yourself with custom page, if you need, something like:
Route::get('/logout', function () { return view('my_logout_view'); });