fix for middleware and static content
This commit is contained in:
parent
e5fb968629
commit
5587f9fb76
|
|
@ -29,6 +29,7 @@ jobs:
|
||||||
node-version: '22'
|
node-version: '22'
|
||||||
|
|
||||||
- run: pnpm install --frozen-lockfile
|
- run: pnpm install --frozen-lockfile
|
||||||
|
- run: pnpm exec prisma generate
|
||||||
- run: pnpm run build
|
- run: pnpm run build
|
||||||
|
|
||||||
- name: Copy build to VPS
|
- name: Copy build to VPS
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,4 @@
|
||||||
import { defineMiddleware } from "astro:middleware";
|
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"]);
|
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/")) {
|
if (pathname.startsWith("/api/admin/")) {
|
||||||
|
const { isApiAuthorized } = await import("./pages/api/lib/auth");
|
||||||
const isAuthEndpoint =
|
const isAuthEndpoint =
|
||||||
pathname.endsWith("/auth/login") || pathname.endsWith("/auth/logout");
|
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);
|
const segments = pathname.split("/").filter(Boolean);
|
||||||
if (segments.length >= 2 && segments[1] === "admin") {
|
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 locale = LOCALES.has(segments[0]) ? segments[0] : "es";
|
||||||
const isLogin = segments[2] === "login";
|
const isLogin = segments[2] === "login";
|
||||||
const session = await getSession(request);
|
const session = await getSession(request);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue