pre-bemis

This commit is contained in:
Marcelo
2026-04-22 05:04:19 +00:00
parent ac1a7900c8
commit 80d27f83b6
91 changed files with 11769 additions and 820 deletions

41
middleware.ts Normal file
View File

@@ -0,0 +1,41 @@
import { NextResponse } from "next/server";
import type { NextRequest } from "next/server";
const COOKIE_NAME = "mis_session";
export function middleware(req: NextRequest) {
try {
const { pathname, search } = req.nextUrl;
if (
pathname.startsWith("/_next") ||
pathname.startsWith("/favicon") ||
pathname.startsWith("/public") ||
pathname === "/login" ||
pathname === "/signup" ||
pathname === "/logout" ||
pathname.startsWith("/invite") ||
pathname.startsWith("/api")
) {
return NextResponse.next();
}
const sessionId = req.cookies.get(COOKIE_NAME)?.value;
if (!sessionId) {
const url = req.nextUrl.clone();
url.pathname = "/login";
url.searchParams.set("next", pathname + search);
return NextResponse.redirect(url);
}
return NextResponse.next();
} catch (err) {
console.error("[middleware]", err);
return NextResponse.next();
}
}
export const config = {
matcher: ["/((?!_next/static|_next/image).*)"],
};