I have the general feeling that the middleware component of nextjs is not loading all resources into the runtime. I am using next.js v17.0.x . Apparently on middleware there is a differnt runtime called "edge" running, which seems not be capable to handle all resources.
Once I try to establish an connection to mongodb, middleware will throw this error:
error - (middleware)/node_modules/next-session/lib/compat.js (1:0) @ Array.ExpressStore error - The edge runtime does not support Node.js 'events' module.
My plan is to check a database session, if it exists, before continuing with the application logic, so basically on connection. In my opinion the middleware component should handle this, if no session is persisting it should redirect, or am I wrong?