import { NextResponse, type NextRequest } from "next/server"; export function middleware(request: NextRequest) { if (request.nextUrl.pathname.startsWith("/w/")) { const hasSessionCookie = request.cookies .getAll() .some((cookie) => cookie.name.includes("session_token")); if (!hasSessionCookie) return NextResponse.redirect( new URL(`/login?next=${encodeURIComponent(request.nextUrl.pathname)}`, request.url), ); } return NextResponse.next(); } export const config = { matcher: ["/w/:path*"] };