Have any of you used next-auth with middleware on next-on-pages without error? I'm trying to do that

Have any of you used next-auth with middleware on next-on-pages without error? I'm trying to do that and everything works good on
npm run dev
but when I try to start it with "preview": "npm run pages:build && wrangler pages dev .vercel/output/static", req.auth starts be always null and I don't know why because I don't getting any error.

middleware.ts
import { NextResponse } from "next/server"

import { auth } from "./auth"

export default auth((req) => {
  const isAuth = req.auth // always returning null when it is run on wrangler pages dev


I use drizzle orm with d1 for database
Was this page helpful?