my routes protected by auth middleware don't redirect to login page
I get this error every time I visit a route protected by auth middleware when am not authenticated and started session
Illuminate\Session\Middleware\StartSession::addCookieToResponse(): Argument #1 ($response) must be of type Symfony\Component\HttpFoundation\Response, null given, called in /home/u684103588/domains/chccug.com/public_html/vendor/laravel/framework/src/Illuminate/Session/Middleware/StartSession.php on line 125
I have alternated the middlewares in the app to no avail
Solution:Jump to solution
Deleted all the default files and installed fresh installation of Laravel 10, added all the custom codes run composer install and every started working perfectly fine
11 Replies
Hello Obala, Can you show us your web.php file? I think the problem is with the routing.
here is my route and the middleware used
Do you have defined, which route (in the UserController) Laravel has to follow when you're not logged in?
yes, they are all setup and working, i only get the error say when i visit /profile without logging in first, butt when i visit route like /login or /register or the front routes which does not require authentication i don't get any error
Can you show me the middleware array in app\Http\Kernel.php? Also, can I see the
use
statement for the Response
class inside the UserController
class
I see that you have a checkUserStatus
in the middleware as well. Can I take a look at that middleware class too?Let me do so in a minute
thats the app\http\kernel.php
CheckuserStatus middleware
usercontroller\
there's this issue with the api routes
i don't if its the cause of this mess
this happens when i run php artisan route:cache
Solution
Deleted all the default files and installed fresh installation of Laravel 10, added all the custom codes run composer install and every started working perfectly fine