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).*)', ], }