This commit is contained in:
asabizanjo
2025-12-11 01:05:24 +00:00
parent c713d58f98
commit 423ce1bc6d
88 changed files with 4081 additions and 122 deletions

20
middleware.ts Normal file
View File

@@ -0,0 +1,20 @@
import { NextResponse } from "next/server";
import type { NextRequest } from "next/server";
import { SESSION_COOKIE_NAME, verifySessionToken } from "./lib/auth";
export async function middleware(req: NextRequest) {
const token = req.cookies.get(SESSION_COOKIE_NAME)?.value;
const session = token ? await verifySessionToken(token) : null;
if (!session) {
const loginUrl = new URL("/login", req.url);
return NextResponse.redirect(loginUrl);
}
return NextResponse.next();
}
export const config = {
matcher: ["/dashboard/:path*", "/api/files/:path*"],
};