return view('auth.login');
It have to redirect you to the login page if you are not logged in. That is how the auth middleware works. Or what do you mean?
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Hi guys, i used
php artisan make:auth
after that I removed everything and wrote my own stuff. I can add a user (register), delete and edit a user. I can log in and that works perfectly fine. The only problem I am facing now is that when I want to protect a route I get this error:
InvalidArgumentException Route [login] not defined.
I did this in my web.php file:
Route::middleware(['auth'])->group(function(){
Can someone help me out on how to fix this?
P.S. I have this in my controller:
return view('auth/login');
and in my folder I have this:
resources/views/auth/login.blade.php
so that shouldnt be a problem either is it?
EDIT: Got it working by adding "->name('login')" to it. But now it keeps redirecting me to the login for some reason when I try to go to a route within the group that i added "auth" to.
@staticcode are you using this?
Auth::routes();
run php artisan route:list and check do you have route with name login . middleware trying to redirect you to route named login but can't find
Please or to participate in this conversation.