Files
Beacon/middleware.ts
T
Uklonil 3aeaed0af2
CI / quality (push) Waiting to run
UPD: initial architecture
2026-07-27 10:23:50 +02:00

15 lines
541 B
TypeScript

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*"] };