diff --git a/pitch-deck/middleware.ts b/pitch-deck/middleware.ts index ba32df7..635afed 100644 --- a/pitch-deck/middleware.ts +++ b/pitch-deck/middleware.ts @@ -67,6 +67,17 @@ export async function middleware(request: NextRequest) { } } + // ----- Allow admins to access investor routes (e.g. /api/chat in preview) ----- + const adminFallback = request.cookies.get('pitch_admin_session')?.value + if (adminFallback && secret) { + try { + await jwtVerify(adminFallback, new TextEncoder().encode(secret), { audience: ADMIN_AUDIENCE }) + return NextResponse.next() + } catch { + // Invalid admin token, fall through to investor auth + } + } + // ----- Investor-gated routes (everything else) ----- const token = request.cookies.get('pitch_session')?.value