Reputation: 441
When user navigation to app ex: http://myapp.mydomain.com I initialize a bunch of stuff, make requests to auth the user based on a cookie etc. This setup the main state of my main-reducer.
If a user navigation directly by pasting let say: http://myapp.mydomain.com/userProfile
The main state, will never be setupped. So the trick I'm using is putting the last part of the url (userProfile) in a cookie (or somewhere else) and redirecting to http://myapp.mydomain.com. After auth and requests, I the redirect back to the page the user wants to view. This works, but feels wrong. I was wondering: is there a better way of doing that?
Thanks!
Upvotes: 0
Views: 157
Reputation: 483
Why don't you just make the route /userProfile
as protected route.
Only if the user is authenticated he can see that page if not redirect to root page and re-validate the user.
Upvotes: 1