I mentioned this briefly in an earlier post on middleware patterns, that direct database queries don't run reliably in middleware, and a few people asked what "not reliably" actually means in practice, since it sounds vague enough to ignore. It's worth a real, specific answer, because the actual...

Source: [Dev.to](https://dev.to/anas_sheikh_2/why-your-mongodb-check-in-nextjs-middleware-might-be-silently-failing-1o3e)

Sponsored