import { NextResponse } from 'next/server' import type { NextRequest } from 'next/server' export function middleware(request: NextRequest) { // Verifica se é uma rota admin if (request.nextUrl.pathname.startsWith('/admin')) { // Excluir a página de login da verificação if (request.nextUrl.pathname === '/admin/login') { return NextResponse.next() } // Verificar se está autenticado const isAuthenticated = request.cookies.get('auth_token') if (!isAuthenticated) { // Redirecionar para login return NextResponse.redirect(new URL('/admin/login', request.url)) } } return NextResponse.next() } export const config = { matcher: ['/admin/:path*'] }