This commit is contained in:
Dominik Klarkowski
2026-06-18 11:02:31 +02:00
parent d00a5a42ac
commit 047e580da0
32 changed files with 735 additions and 189 deletions

23
middleware.ts Normal file
View File

@@ -0,0 +1,23 @@
import { auth } from "@/auth";
import { NextResponse } from "next/server";
export default auth((req) => {
const isAuthenticated = !!req.auth;
const { pathname } = req.nextUrl;
if (!isAuthenticated && pathname !== "/login") {
return NextResponse.redirect(new URL("/login", req.url));
}
if (isAuthenticated && pathname === "/login") {
return NextResponse.redirect(new URL("/", req.url));
}
return NextResponse.next();
});
export const config = {
matcher: [
"/((?!api/auth|_next/static|_next/image|favicon.ico|icon.svg|logo.svg|public/).*)",
],
};