2025-09-12 20:40:17 -06:00
|
|
|
import { NextResponse } from "next/server";
|
|
|
|
|
import type { NextRequest } from "next/server";
|
|
|
|
|
|
|
|
|
|
export function middleware(request: NextRequest) {
|
2026-01-09 15:29:35 -06:00
|
|
|
const token = request.cookies.get("token")?.value;
|
|
|
|
|
const pathname = request.nextUrl.pathname;
|
|
|
|
|
|
2026-01-12 13:57:08 -06:00
|
|
|
if (pathname === "/" && token) {
|
|
|
|
|
return NextResponse.redirect(new URL("/Impresiones", request.url));
|
2026-01-09 15:29:35 -06:00
|
|
|
}
|
2025-09-12 20:40:17 -06:00
|
|
|
|
2026-01-12 13:57:08 -06:00
|
|
|
if (!token && pathname != "/") {
|
2026-01-09 15:29:35 -06:00
|
|
|
console.log("No hay token, redirigiendo a login");
|
2025-09-12 20:40:17 -06:00
|
|
|
return NextResponse.redirect(new URL("/", request.url));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return NextResponse.next();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export const config = {
|
2026-02-05 13:26:17 -06:00
|
|
|
matcher: [
|
|
|
|
|
"/",
|
2026-01-09 15:15:55 -06:00
|
|
|
"/Reportes",
|
|
|
|
|
"/Monitor",
|
|
|
|
|
"/QuitarSancion",
|
|
|
|
|
"/Programas",
|
|
|
|
|
"/Mensajes",
|
|
|
|
|
"/Inscritos",
|
|
|
|
|
"/Inscripciones",
|
|
|
|
|
"/InformacionEquipo",
|
|
|
|
|
"/Impresiones",
|
|
|
|
|
"/CambiarPass",
|
|
|
|
|
"/BitacoraSanciones",
|
|
|
|
|
"/AsignacionMesas",
|
|
|
|
|
"/AsignacionEquipo",
|
|
|
|
|
"/Alta",
|
|
|
|
|
"/AgregarTiempo",
|
|
|
|
|
"/ActivosMantenimiento",
|
|
|
|
|
],
|
2025-09-12 20:40:17 -06:00
|
|
|
};
|
2026-01-09 15:33:46 -06:00
|
|
|
//IO
|