Middleware will soon support using the Node.js runtime, if you want. However, you still shouldn't run blocking database queries there. There's where the framework is currently trying to push you towards, but not doing so well enough to understand that tradeoff. That's why there is a supplemental API being added: https://github.com/vercel/next.js/pull/70961