You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've encountered a strange behavior when using nested routes in my Solid Start application. Specifically, when I added an additional routes group and nested an authenticated route within it, the application started redirecting me to the login page instead of the expected home page ("/") after logging out.
It seems that $isAuthenticated may be becoming false before the redirect completes, causing the application to redirect back to the login page.
When an unauthenticated user navigates from / to /settings it logs "<Authenticated />", and then /settings → /loginredication happens but "<Authenticated /> cleanup"doesn't get called. Then, after pusing the "Login" button, /login to /settingsredirection happens and "<Authenticated />" gets logged, then on logout "<Authenticated /> cleanup" gets called.
There appears to be a lingering reactive state (<Switch />/<Match /> still hanging around and being reactive) in the Solid Router that does not clean up properly after logging out, leading to unexpected behavior.
Also, try removing the /(group) folder and the (group).tsx and move everything to the root of the /routes folder. There won't be such behavior.
Navigate to the /about or /settings route (protected). It will redirect you to the /login route as you're not authenticated.
Log in with any credentials.
Navigate to the /settings route (protected). It won't redirect you now as you're authenticated now.
Push the "Logout" button on the /settings page.
Observe the incorrect redirect behavior:
Redirects to / first.
Redirects to /login?redirect=%2F(unexpected).
Expected behavior
After logging out, it should redirect only to / and then not to /login.
Screenshots or Videos
Actual behavior
Video with steps to reproduce
2024-08-17.15-27-55.mp4
Missing console log
Expected behavior
Note, this is true when you'll remove the /(group) folder and the (group).tsx and move everything to the root of the /routes folder.
2024-08-17.16-22-24.mp4
Platform
OS: Microsoft Windows [Version 10.0.22621.4037]
Browser: Google Chrome [Version 127.0.6533.120]
Additional context
A common use case for implementing such groups is in scenarios where there is a sidebar navigation for an index page that is accessible to all users, regardless of their authentication status. Additionally, for protected routes, the sidebar should be also present, but it should not be displayed for such routes as /login or /register.
Interesting.. This only seems to happen under a very specific set of steps. It is vital that you login on a page that was a redirect to the /settings page for this to happen. And I think that is where the bug is. It happens before we ever log in. There is a stranded /settings page. Why is interesting. I will look into it.
Describe the bug
I've encountered a strange behavior when using nested routes in my Solid Start application. Specifically, when I added an additional routes group and nested an authenticated route within it, the application started redirecting me to the login page instead of the expected home page ("/") after logging out.
As @Brendonovich mentioned in Discord:
$isAuthenticated
may be becomingfalse
before the redirect completes, causing the application to redirect back to the login page./
to/settings
it logs"<Authenticated />"
, and then/settings
→/login
redication happens but"<Authenticated /> cleanup"
doesn't get called. Then, after pusing the "Login" button,/login
to/settings
redirection happens and"<Authenticated />"
gets logged, then on logout"<Authenticated /> cleanup"
gets called.<Switch />
/<Match />
still hanging around and being reactive) in the Solid Router that does not clean up properly after logging out, leading to unexpected behavior.Also, try removing the
/(group)
folder and the(group).tsx
and move everything to the root of the/routes
folder. There won't be such behavior.Your Example Website or App
https://github.com/zobweyt/solid-start-auth-example
Steps to Reproduce the Bug or Issue
/about
or/settings
route (protected). It will redirect you to the/login
route as you're not authenticated./settings
route (protected). It won't redirect you now as you're authenticated now./settings
page./
first./login?redirect=%2F
(unexpected).Expected behavior
After logging out, it should redirect only to
/
and then not to/login
.Screenshots or Videos
Actual behavior
Video with steps to reproduce
2024-08-17.15-27-55.mp4
Missing console log
Expected behavior
Note, this is true when you'll remove the
/(group)
folder and the(group).tsx
and move everything to the root of the/routes
folder.2024-08-17.16-22-24.mp4
Platform
10.0.22621.4037
]127.0.6533.120
]Additional context
A common use case for implementing such groups is in scenarios where there is a sidebar navigation for an index page that is accessible to all users, regardless of their authentication status. Additionally, for protected routes, the sidebar should be also present, but it should not be displayed for such routes as
/login
or/register
.Related Issues
The text was updated successfully, but these errors were encountered: