Skip to content
Discussion options

You must be logged in to vote

You can access the location object in the beforeLoad function

export const adminIndexRoute = new Route({
    getParentRoute: () => adminLayout,
    path: "/",
    beforeLoad: async({ location}) => {
     
      if(localStorage.getItem("admin") === null) {
        throw redirect({
          to: "/auth",
          search: {
            // Use the current location to power a redirect after login
            // (Do not use `router.state.resolvedLocation` as it can
            // potentially lag behind the actual current location)
            redirect: location.href
          },
        });
      }
    },
});

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@Angusross111
Comment options

Answer selected by tigawanna
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants