Question 💬
I can't get the getServerSession to work in a middleware. I'm using the new Next 13 app directory and I placed the middleware.ts file in the root of my project. When I try to open a URL that matches the middleware and goes through it, I get the following error:
- error node_modules\oidc-token-hash\lib\shake256.js (3:0) @ <unknown>
- error Cannot read properties of undefined (reading 'substring')
How to reproduce ☕️
import type { NextRequest } from 'next/server';
import { getServerSession } from 'next-auth';
import { authOptions } from '@/utils/auth-options';
// This function can be marked `async` if using `await` inside
export async function middleware(request: NextRequest) {
const session = await getServerSession(authOptions);
console.log('session', session);
}
// See "Matching Paths" below to learn more
export const config = {
matcher: [
'/((?!api|_next/static|_next/image|favicon.ico|robots.txt|sitemap.xml).*)',
],
};
Contributing 🙌🏽
Yes, I am willing to help answer this question in a PR
Question 💬
I can't get the getServerSession to work in a middleware. I'm using the new Next 13 app directory and I placed the
middleware.tsfile in the root of my project. When I try to open a URL that matches the middleware and goes through it, I get the following error:How to reproduce ☕️
Contributing 🙌🏽
Yes, I am willing to help answer this question in a PR