41 lines
934 B
TypeScript
41 lines
934 B
TypeScript
import { NextResponse } from "next/server";
|
|
import type { NextRequest } from "next/server";
|
|
|
|
export function proxy(request: NextRequest) {
|
|
const token = request.cookies.get("token")?.value;
|
|
const pathname = request.nextUrl.pathname;
|
|
|
|
if (pathname === "/" && token) {
|
|
return NextResponse.redirect(new URL("/Impresiones", request.url));
|
|
}
|
|
|
|
if (!token && pathname != "/") {
|
|
console.log("No hay token, redirigiendo a login");
|
|
return NextResponse.redirect(new URL("/", request.url));
|
|
}
|
|
|
|
return NextResponse.next();
|
|
}
|
|
|
|
export const config = {
|
|
matcher: [
|
|
"/",
|
|
"/Reportes",
|
|
"/Monitor",
|
|
"/QuitarSancion",
|
|
"/Programas",
|
|
"/Mensajes",
|
|
"/Inscritos",
|
|
"/Inscripcion",
|
|
"/InformacionEquipo",
|
|
"/Impresiones",
|
|
"/CambiarPass",
|
|
"/BitacoraSanciones",
|
|
"/AsignacionMesas",
|
|
"/AsignacionEquipo",
|
|
"/Alta",
|
|
"/AgregarTiempo",
|
|
"/ActivosMantenimiento",
|
|
],
|
|
};
|
|
//IO
|