diff --git a/.gitea/workflows/deploy.yaml b/.gitea/workflows/deploy.yaml index 264d40f..15f0d15 100644 --- a/.gitea/workflows/deploy.yaml +++ b/.gitea/workflows/deploy.yaml @@ -29,6 +29,7 @@ jobs: node-version: '22' - run: pnpm install --frozen-lockfile + - run: pnpm exec prisma generate - run: pnpm run build - name: Copy build to VPS diff --git a/src/middleware.ts b/src/middleware.ts index 0d6bb1f..4d4c6e5 100644 --- a/src/middleware.ts +++ b/src/middleware.ts @@ -1,5 +1,4 @@ import { defineMiddleware } from "astro:middleware"; -import { getSession, isApiAuthorized } from "./pages/api/lib/auth"; const LOCALES = new Set(["es", "en", "fr", "he", "uk", "pt", "ru", "rw", "kr"]); @@ -12,6 +11,7 @@ export const onRequest = defineMiddleware(async (context, next) => { } if (pathname.startsWith("/api/admin/")) { + const { isApiAuthorized } = await import("./pages/api/lib/auth"); const isAuthEndpoint = pathname.endsWith("/auth/login") || pathname.endsWith("/auth/logout"); @@ -34,6 +34,7 @@ export const onRequest = defineMiddleware(async (context, next) => { const segments = pathname.split("/").filter(Boolean); if (segments.length >= 2 && segments[1] === "admin") { + const { getSession } = await import("./pages/api/lib/auth"); const locale = LOCALES.has(segments[0]) ? segments[0] : "es"; const isLogin = segments[2] === "login"; const session = await getSession(request);