z4nr34l / nemo

Missing polyfill for multiple next.js middlewares
https://nemo.rescale.build
MIT License
152 stars 6 forks source link

Problem with Authjs V5 #106

Open miticdjd opened 1 month ago

miticdjd commented 1 month ago

Hey @z4nr34l ,

First of all, thank you for this package. It is beneficial!

Describe the bug When I switched from next-easy-middlewares to new @rescale/nemo, I started having a problem with AuthJS v5. I am getting an error: Error [TypeError]: Cannot use 'in' operator to search for 'headers' in undefined.

Before, I used the next-easy-middleware v1.1.6, now @rescale/Nemo v1.2.2.

To Reproduce Steps to reproduce the behavior: Packages: @rescale/nemo v1.1.6 next v14.2.5 authjs v5 node v20.15.1

middlewares.tsx

import { createMiddleware } from '@rescale/nemo'
import { auth } from '@/auth'

const globalMiddlewares = {
  before: auth,
}

const middlewares = {}

// create middleware
export const middleware = createMiddleware(middlewares, globalMiddlewares);

export const config = {
  matcher: ["/((?!api|_next/static|_next/image|favicon.ico).*)"],
}

Expected behavior Auth middleware to work.

Additional context Screenshot 2024-08-09 at 14 23 30 Screenshot 2024-08-09 at 14 23 57

linear[bot] commented 1 month ago

NEMO-24 Problem with Authjs V5

z4nr34l commented 4 weeks ago

next-auth middleware API is not compatible with new (more elastic) approach introduced in nemo. I will prepare an example and docs how to overcome this compatibility issues!

miticdjd commented 4 weeks ago

Yeah, I assumed that was the case. Thanks a lot in advance!