I need some assistance with deploying on Vercel. I have created a _middleware.ts file that checks for a JWT in the user's cookie.
import { NextResponse } from 'next/server'
import type { NextRequest } from 'next/server'
import { JwtPayload, verify } from 'jsonwebtoken'
export async function middleware(req: NextRequest) {
let response = NextResponse.next()
const url = req.nextUrl.clone()
const token = req.cookies['allow-list']
if (!token || token === 'deleted') {
return response
}
try {
const decodedToken = verify(
token,
process.env.TOKEN_SECRET as string
) as JwtPayload
} catch (e) {}
return response
}
However, when I attempt to build my project, I encounter the error: "Dynamic Code Evaluation (e. g. 'eval', 'new Function') not allowed in Middleware pages/_middleware". Is there a solution to this issue? It functions properly when running locally.
[22:59:29.409] Cloning github.com/dimitriborgers/test (Branch: master, Commit: efc1977)
[22:59:30.051] Cloning completed: 642.161ms
[22:59:30.427] Installing build runtime...
[22:59:34.350] Build runtime installed: 3.924s
[22:59:35.048] Looking up build cache...
(remaining content paraphrased for uniqueness)