diff --git a/proxy.ts b/middleware.ts similarity index 89% rename from proxy.ts rename to middleware.ts index fcc7722..3cbef69 100644 --- a/proxy.ts +++ b/middleware.ts @@ -3,10 +3,11 @@ import type { NextRequest } from 'next/server'; import { jwtVerify } from 'jose'; const SESSION_COOKIE_NAME = 'logbuch_session'; -const secretKey = process.env.AUTH_SECRET || 'logbuch-secret-change-in-production'; +const secretKey = process.env.AUTH_SECRET; +if (!secretKey) throw new Error('AUTH_SECRET Umgebungsvariable ist nicht gesetzt!'); const key = new TextEncoder().encode(secretKey); -export async function proxy(request: NextRequest) { +export async function middleware(request: NextRequest) { const { pathname } = request.nextUrl; if (pathname.startsWith('/login') || pathname.startsWith('/_next') || pathname.startsWith('/favicon')) {