const indexRoute = new Route({
getParentRoute: () => rootRoute,
path: "/",
beforeLoad: ({ buildLocation, location, navigate }) => {
if (!isUserSignedIn()) {
throw redirect({
to: loginRoute.to,
search: { redirect: location.href },
});
}
const isOnHomePage =
buildLocation({ to: indexRoute.path }).pathname === location.pathname;
if (isOnHomePage) navigate({ to: defaultLoggedInRoute.to });
},
});
const indexRoute = new Route({
getParentRoute: () => rootRoute,
path: "/",
beforeLoad: ({ buildLocation, location, navigate }) => {
if (!isUserSignedIn()) {
throw redirect({
to: loginRoute.to,
search: { redirect: location.href },
});
}
const isOnHomePage =
buildLocation({ to: indexRoute.path }).pathname === location.pathname;
if (isOnHomePage) navigate({ to: defaultLoggedInRoute.to });
},
});