feat: add index route with auth guard and redirect logic
This commit is contained in:
parent
be584ccfa7
commit
d05bfa3264
2 changed files with 16 additions and 0 deletions
|
|
@ -2,6 +2,7 @@ import { createRouter } from "@tanstack/react-router";
|
|||
import { Route as rootRoute } from "./routes/__root";
|
||||
import { Route as chatRoute } from "./routes/chat";
|
||||
import { Route as gridTestRoute } from "./routes/grid-test";
|
||||
import { Route as indexRoute } from "./routes/index";
|
||||
import { Route as loginRoute } from "./routes/login";
|
||||
import { Route as onboardingRoute } from "./routes/onboarding";
|
||||
import { Route as exportRoute } from "./routes/export";
|
||||
|
|
@ -9,6 +10,7 @@ import { Route as signupRoute } from "./routes/signup";
|
|||
import { Route as studioRoute } from "./routes/studio";
|
||||
|
||||
const routeTree = rootRoute.addChildren([
|
||||
indexRoute,
|
||||
onboardingRoute,
|
||||
loginRoute,
|
||||
signupRoute,
|
||||
|
|
|
|||
14
studio/frontend/src/app/routes/index.tsx
Normal file
14
studio/frontend/src/app/routes/index.tsx
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
import { createRoute, redirect } from "@tanstack/react-router";
|
||||
import { getPostAuthRoute } from "@/features/auth";
|
||||
import { requireAuth } from "../auth-guards";
|
||||
import { Route as rootRoute } from "./__root";
|
||||
|
||||
export const Route = createRoute({
|
||||
getParentRoute: () => rootRoute,
|
||||
path: "/",
|
||||
beforeLoad: async () => {
|
||||
await requireAuth();
|
||||
throw redirect({ to: getPostAuthRoute() });
|
||||
},
|
||||
component: () => null,
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue