diff --git a/docker-compose.override.yml b/docker-compose.override.yml index 0751abe901..7fcea21788 100644 --- a/docker-compose.override.yml +++ b/docker-compose.override.yml @@ -101,6 +101,9 @@ services: args: - VITE_API_URL=http://localhost:8000 - NODE_ENV=development + depends_on: + backend: + condition: service_healthy playwright: build: diff --git a/frontend/src/routes/_layout/index.tsx b/frontend/src/routes/_layout/index.tsx index 66e32e0b30..ab23f4e11e 100644 --- a/frontend/src/routes/_layout/index.tsx +++ b/frontend/src/routes/_layout/index.tsx @@ -1,10 +1,17 @@ import { Box, Container, Text } from "@chakra-ui/react" -import { createFileRoute } from "@tanstack/react-router" +import { createFileRoute, redirect } from "@tanstack/react-router" -import useAuth from "@/hooks/useAuth" +import useAuth, { isLoggedIn } from "@/hooks/useAuth" export const Route = createFileRoute("/_layout/")({ component: Dashboard, + beforeLoad: async () => { + if (!isLoggedIn()) { + throw redirect({ + to: "/login", + }) + } + }, }) function Dashboard() {