excluding root

This commit is contained in:
IO420
2026-01-09 15:29:35 -06:00
parent b5d4b355ac
commit bb701b49bf
+7 -3
View File
@@ -2,10 +2,15 @@ import { NextResponse } from "next/server";
import type { NextRequest } from "next/server";
export function middleware(request: NextRequest) {
const token = request.cookies.get("token");
const token = request.cookies.get("token")?.value;
const pathname = request.nextUrl.pathname;
if (pathname === "/") {
return NextResponse.next();
}
if (!token) {
console.log("No hay token, redirigiendo a la página de inicio de sesión");
console.log("No hay token, redirigiendo a login");
return NextResponse.redirect(new URL("/", request.url));
}
@@ -32,4 +37,3 @@ export const config = {
"/ActivosMantenimiento",
],
};
//IO