Welcome to the CSC Q&A, on our server named in honor of Ada Lovelace. Write great code! Get help and give help!
It is our choices... that show what we truly are, far more than our abilities.

Categories

+8 votes

We are using react-router to switch between different pages. After logging in, the route is still set to /login until you press the tap on the navbar of the page you want to route to next. Is there a way to have the project go straight to the /home page after logging in?

The typical solution to this problem is setting the home page as the default / route but because the /login doesn't clear until a new nav is chosen I am having trouble finding a solution.

asked in CSC490_Spring202021 by (1 point)

1 Answer

+2 votes

You can have a redirect in the callback function after successfully login. Or you can have a check if the user exists or not (using cookie, token). If yes, call the main router whose default route is /home, if not call the authentication router, whose default route is /login

answered by (1 point)
...