This commit is contained in:
2026-04-15 09:29:54 +00:00
parent 52973e9581
commit 4e3d0f28c4
10 changed files with 10471 additions and 3 deletions

28
middleware.ts Normal file
View File

@@ -0,0 +1,28 @@
import { NextResponse } from 'next/server'
import type { NextRequest } from 'next/server'
/**
* 中间件:主要用于 API 路由的认证检查
* 客户端的 token 验证在页面组件中处理(因为 middleware 无法访问 localStorage
*/
export function middleware(request: NextRequest) {
const { pathname } = request.nextUrl
// API 路由的认证检查在各自的 route.ts 中处理
// 页面路由的认证检查在客户端组件中处理(使用 useAuth hook
return NextResponse.next()
}
export const config = {
matcher: [
/*
* Match all request paths except for the ones starting with:
* - api (API routes)
* - _next/static (static files)
* - _next/image (image optimization files)
* - favicon.ico (favicon file)
*/
'/((?!api|_next/static|_next/image|favicon.ico).*)',
],
}