middleware.ts
export { default } from 'next-auth/middleware';
export const config = { matcher: ['/my/:path*'] };
https://next-auth.js.org/configuration/nextjs#middleware
now im using like this, but code is not working
I hope middleware works when accessing pages related to 'my'. how can i fix it?
"next": "^12.0.8",
"next-auth": "^4.10.3",
"react": "^18.2.0",
"react-dom": "^18.2.0",
this is my packages version
I think the issue might be the way in which you are creating the middleware
file, since everything else looks good to me.
Since Next.js 12.2, now you have to create a single middleware.ts
file in your root directory (same level as pages
folder). But on earlier versions like the one you are using, you need to create a _middleware.ts
(notice the underscore) file inside your pages
folder.
Reference: https://nextjs.org/docs/messages/middleware-upgrade-guide#breaking-changes