I have an application with next-auth and a simple login with jwt but when i use the middleware in next js to check the next-auth's session is exists , but what if the user log in with the simple login (username & pwd ) , i try to store my jwt from the simple login in cookies but the middleware is in the backend and it can't connect to the frontend , here is my middleware
import {NextResponse} from "next/server";
export async function middleware(req) {
let token = await getToken({req,secret: process.env.NEXTAUTH_SECRET})
let {pathname} = req.nextUrl;
if(pathname.includes("/api/auth") || token) return NextResponse.next();
if( !token && pathname !== "/login") return NextResponse.redirect(`${process.env.NEXTAUTH_URL}/login`); // if there is no jwt or token or the user not comming from /login then redirect him to /login
}
How can i check the jwt token from the simple log in and the token from next-auth in the same middleware because when i try to log in with the simple it's not redirect me to the the homeenter image description here