diff --git a/middleware.ts b/middleware.ts index c7f08d0..945d92e 100644 --- a/middleware.ts +++ b/middleware.ts @@ -1,16 +1,16 @@ import { NextRequest, NextResponse } from "next/server" import { getCookieCache } from "better-auth/cookies" -const PUBLIC_PATHS = [/^\/login$/, /^\/api\/auth/, /^\/_next\//, /^\/favicon/] +// Rotas públicas explícitas (não autenticadas) +const PUBLIC_PATHS = [/^\/login$/] +// Rotas somente admin const ADMIN_ONLY_PATHS = [/^\/admin(?:$|\/)/] const APP_HOME = "/dashboard" export async function middleware(request: NextRequest) { const { pathname, search } = request.nextUrl - if (PUBLIC_PATHS.some((pattern) => pattern.test(pathname))) { - return NextResponse.next() - } + if (PUBLIC_PATHS.some((pattern) => pattern.test(pathname))) return NextResponse.next() const session = await getCookieCache(request) @@ -37,6 +37,8 @@ export async function middleware(request: NextRequest) { } export const config = { - runtime: "nodejs", - matcher: ["/(.*)"], + // Evita executar para assets e imagens estáticas + matcher: [ + "/((?!api|_next/static|_next/image|favicon.ico|icon.png).*)", + ], }