Add auth and theme switcher

This commit is contained in:
2025-07-04 18:53:15 +02:00
parent f3c92cdab6
commit a12a8e4e1b
13 changed files with 858 additions and 33 deletions

24
src/middleware.ts Normal file
View File

@ -0,0 +1,24 @@
import { auth } from "@/auth"
import type { NextRequest } from "next/server"
import { NextResponse } from "next/server"
export async function middleware(request: NextRequest) {
const session = await auth()
const isProtectedPath =
!request.nextUrl.pathname.startsWith("/api/auth") &&
!request.nextUrl.pathname.startsWith("/_next") &&
!request.nextUrl.pathname.startsWith("/favicon") &&
!request.nextUrl.pathname.startsWith("/assets")
if (isProtectedPath && !session) {
const signInUrl = new URL("/api/auth/signin", request.url)
return NextResponse.redirect(signInUrl)
}
return NextResponse.next()
}
export const config = {
matcher: ["/((?!api/auth|_next/static|_next/image|favicon.ico).*)"],
}