Skip to content
Discussion options

You must be logged in to vote

You need to check whether the path is trying to access the protected pages, like

beforeNavigate(({ to, cancel }) => {
  if (to?.pathname.startsWith('/<protected url>') && !localStorage.getItem("token")) {
	  cancel();
	  goto("/panel/login");
  }
});

So, the goto("/panel/login") will not redirect again.
But there's a short period of time the protected page will display before beforeNavigate trigger.

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by HenrijsS
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants