You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
19 lines
530 B
19 lines
530 B
// middleware.ts
|
|
import { NextResponse } from 'next/server'
|
|
import type { NextRequest } from 'next/server'
|
|
|
|
|
|
export async function middleware(request: NextRequest) {
|
|
|
|
//Validar si la url solicitada está dentro del listado de enlaces permitidos
|
|
const token = request.cookies.get('token')?.value
|
|
|
|
if (!token) {
|
|
return NextResponse.rewrite(new URL('/login', request.url))
|
|
}
|
|
}
|
|
|
|
// See "Matching Paths" below to learn more
|
|
export const config = {
|
|
matcher: ['/((?!api|_next/static|_next/image|favicon.ico|login).*)',],
|
|
} |