Environment
System:
OS: Linux 5.19 Debian GNU/Linux 10 (buster) 10 (buster)
CPU: (12) x64 AMD Ryzen 5 5600H with Radeon Graphics
Memory: 123.65 MB / 5.65 GB
Container: Yes
Shell: 5.0.3 - /bin/bash
Binaries:
Node: 16.13.2 - /usr/local/bin/node
Yarn: 1.22.15 - /usr/local/bin/yarn
npm: 8.1.2 - /usr/local/bin/npm
npmPackages:
next: ^13.0.0 => 13.0.0
next-auth: ^4.15.0 => 4.15.0
react: 18.2.0 => 18.2.0
Reproduction URL
https://github.com/nextauthjs/next-auth-example
Describe the issue
I follow this tutorial in official document next-auth, when i custom jwt method ( encode, decode )
NextAuthOptions: pages/api/auth/[...nextauth].ts
jwt: {
maxAge: 60 * 60 * 24 * 14,
async encode({ token: payload, secret }) {
return jwt.sign(payload, secret);
},
async decode({ token, secret }) {
return jwt.verify(token, secret) as any;
},
}
and pass decode method above to middleware
middleware.ts
and i got error

How to reproduce
- Clone https://github.com/nextauthjs/next-auth-example
- Replace jwt options with above options and pass jwt decode to middleware
- Access localhost:3000 and login
Expected behavior
Can get token in middleware when use custom jwt method
Environment
System:
OS: Linux 5.19 Debian GNU/Linux 10 (buster) 10 (buster)
CPU: (12) x64 AMD Ryzen 5 5600H with Radeon Graphics
Memory: 123.65 MB / 5.65 GB
Container: Yes
Shell: 5.0.3 - /bin/bash
Binaries:
Node: 16.13.2 - /usr/local/bin/node
Yarn: 1.22.15 - /usr/local/bin/yarn
npm: 8.1.2 - /usr/local/bin/npm
npmPackages:
next: ^13.0.0 => 13.0.0
next-auth: ^4.15.0 => 4.15.0
react: 18.2.0 => 18.2.0
Reproduction URL
https://github.com/nextauthjs/next-auth-example
Describe the issue
I follow this tutorial in official document next-auth, when i custom jwt method ( encode, decode )
and pass decode method above to middleware
and i got error

How to reproduce
Expected behavior
Can get token in middleware when use custom jwt method