Currently, I am utilizing next.js version 13.4.12 with next-auth version 4.22.3 and prisma version 5.0.0, while also incorporating @next-auth/prisma-adapter version 1.0.7 in a TypeScript setup.
Additionally, I have diligently followed all the necessary boilerplate instructions as outlined in the official documentation.
Contained within my middleware.ts file is the following code snippet:
import withAdminsAuthentication from "./middleware/admin";
import withUserAuthentication from "./middleware/auth";
import { stackMiddlewares } from "./middleware/stackMiddlewares";
const middlewares = [withUserAuthentication, withAdminsAuthentication];
// The stackMiddleware function effectively chains the specified list of middlewares
export default stackMiddlewares(middlewares);
As for my auth.ts middleware file, its contents are detailed below:
// Content here
Moreover, inside the @lib/auth.ts file, the next-auth options are exported like this:
// Code block here
Listed below is the error stacktrace encountered:
// Error details here
A recent update was made to the codebase where changes were implemented in the admin middleware file:
// New code snippet here
Subsequently following further inspection through debugging, it was discovered that the issue stemmed from the usage of Prisma in the middleware functions. This predicament has left me perplexed as the adminsOnlyRoutes array remains empty but the error persists. It appears that certain restrictions exist regarding the integration of Prisma within the middleware logic.
If anyone can shed light on this matter or propose potential solutions, it would be greatly appreciated.