This commit is contained in:
eric
2025-11-13 05:05:53 +08:00
parent cbdc65f56e
commit 891af61146
691 changed files with 83952 additions and 0 deletions

22
middleware.ts Normal file
View File

@@ -0,0 +1,22 @@
import { auth } from '@/lib/auth'
import { NextResponse } from 'next/server'
import type { NextRequest } from 'next/server'
export async function middleware(request: NextRequest) {
if (request.nextUrl.pathname.startsWith('/admin')) {
const session = await auth()
if (!session?.user) {
const callbackUrl = request.url
return NextResponse.redirect(
new URL(`/auth/signin?callbackUrl=${encodeURIComponent(callbackUrl)}`, request.url)
)
}
}
return NextResponse.next()
}
export const config = {
matcher: ['/admin/:path*']
}