A library to monkey-patch NextAuth to use Session cookies via Next.js middleware.
This allows to force the session-token
cookies to only have Session
level expiry.
This is needed because it's not provided by NextAuth by default: nextauthjs/next-auth#4693
- add the library
npm install next-auth-cookie-fix
- add the following middleware to your app:
import { setAuthCookieExpiryToSession } from 'next-auth-cookie-fix'; export const middleware = setAuthCookieExpiryToSession; // this needs to only match the document queries export const config = { matcher: ['/'] };