My app working in local host. But when I deploy it on vercel it fires an error.
I fixed all errors. I use typescript in my project. Here also my _middleware.tsx file
import { getToken } from "next-auth/jwt";
import { NextResponse } from "next/server";
/** @param {import("next/server").NextRequest} req */
export async function middleware(req) {
if (req.nextUrl.pathname === "/middleware-protected") {
const session = await getToken({
req,
secret: process.env.SECRET,
secureCookie:
process.env.NEXTAUTH_URL?.startsWith("https://") ??
!!process.env.VERCEL_URL,
});
// You could also check for any property on the session object,
// like role === "admin" or name === "John Doe", etc.
if (!session) return NextResponse.redirect("/api/auth/signin");
// If user is authenticated, continue.
}
}
I read the documentation and I searched in here but couldn't find any solution