TanStackT
TanStack2y ago
2 replies
moderate-tomato

Login redirect not loading content after login again

I tried using
navigate({ to: redirect });
but what happens it fails with
An error occurred: Invariant failed: Attempting to navigate to external url with this.navigate!
when navigating to (search.redirect = http://localhost:5173/dashboard/calender). As i guess it only wants the relative path which makes sense. Then I tried using
  React.useLayoutEffect(() => {
    if (auth.isAuth && search.redirect) {
      router.history.push(search.redirect);
    }
  }, [auth, search.redirect]);
Which then does push the url, but doesn't actually seem to navigate and load the content. Only after a refresh. I guess i could just use the routes relative path when setting the search param or is it better to use the href ?
Was this page helpful?