Valid routes/URLs should work whether the user is logged in or not. If the route requires authentication, then redirect to login/register page.
Invalid routes should show error page whether they are logged in or not
Ideas:
Add a AuthenticatedRoute component. Usage would be like this:
<Route path="/user/:username" element={<AuthenticatedRoute element={<Profile />} />
This would automatically redirect the user to the login or register page if they are not authenticated.
Managing routes on the front end could be better.
Ideas:
AuthenticatedRoute
component. Usage would be like this:<Route path="/user/:username" element={<AuthenticatedRoute element={<Profile />} />
This would automatically redirect the user to the login or register page if they are not authenticated.