Hi so I have the following middleware:
import { NextResponse } from "next/server";
import type { NextRequest } from 'next/server'
import { decode } from 'next-auth/jwt';
export default async function middleware(req: NextRequest) {
//console.log(req.cookies.get("next-auth.session-token"));
const sessionToken = req.cookies.get("next-auth.session-token")?.value;
const decoded = await decode({
token: sessionToken,
secret: process.env.NEXTAUTH_SECRET || '',
});
if (!decoded) return NextResponse.redirect(process.env.MIDDLEWARE_REDIRECT || '');
return NextResponse.next();
}
export const config = {
matcher: ['/dashboard'],
}
is this considered safe? Wouldnt it be remarkably easy to fake a jwe in this case to bypass?