Answer the question
In order to leave comments, you need to log in
How to check authorization in react router?
There is a backing on java, authorization takes place on it and cookies are sent to the client. What needs to be done with react router so that the user cannot get to this or that page if he is not logged in?
I also read about JWT but I don’t understand how to use it.
Thanks
Answer the question
In order to leave comments, you need to log in
An example of a private route . I have taken from "state.session.user" - you can check cookie or jwt.
For cookies - document.cookie
for jwt - just jwt.decode function and pass token as parameter.
more details about the private route are in the video . (52:40)
It is necessary to save cookies from the user state when the application is initialized, and then you need to check the page - if there is a user, then render the desired component, and if not, then redirect, for example, to the authorization page
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question