https://github.com/nextauthjs/next-auth/issues/11544#issuecomment-2538494101
I used this fix. Change your middleware to be
export default await auth((req) => { // my custom logic here })