I've a problem when i use _middleware in next js , I want to get the jwt token and check it in that _middleware , that's my code :
import {NextResponse} from "next/server";
import {verify} from "jsonwebtoken";
export async function middleware(req) {
let { cookies } = req;
let token = await cookies.jwt
let url = req.url;
if(url.includes('/dashbord')){
if(token === undefined) return NextResponse.redirect(process.env.NEXTAUTH_URL+'login');
try {
verify(token,process.env.PASSWORD_SECRET);
return NextResponse.next();
} catch (err) {
return NextResponse.redirect(process.env.NEXTAUTH_URL+'login');
}
}
return NextResponse.next();
}
The code works in the localhost very well but when i deploy it , it give me an error **Failed to compile. ** All the envirement variables are setting