I am learning Laravel for a few days now. While checking the kernel.php file i added the Authenticate middleware in the global middleware array, which by default has only the CheckForMaintenanceMode middleware.
protected $middleware = [
\Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode::class,
\Illuminate\Auth\Middleware\Authenticate::class
];
But since adding the Authenticate middleware i am unable to reach(i don't mean access, i mean reach the page itself) any page on my browser. On chrome it says something like this:
"This page isn’t working
blog.dev redirected you too many times.
Try clearing your cookies.
ERR_TOO_MANY_REDIRECTS"
Can anyone please tell why? If i remove the Authenticate middleware the pages are reachable again. Note that i have no middleware registered in my web.php file for the routes. Just trying to understand how things work with authentication in Larave.
You have added Authenticate
middleware as a global middleware.
Excerpt from the documentation -
If you want a middleware to run during every HTTP request to your application, simply list the middleware class in the $middleware
property of your app/Http/Kernel.php
class.
If you are not logged in you can not access any page & to login you have to access atleast login form. But you can't cause you're not logged in. This creates infinte loop.
Thats why you're unable to access any page.
Reference - https://laravel.com/docs/5.4/middleware#registering-middleware