4 ms·
>My final gripe is with middleware. Why does it always run on the Edge? Why limit it from running database queries or using Node.js modules? A lot of the answe
by sergiotapia 2y ago
>My final gripe is with middleware. Why does it always run on the Edge? Why limit it from running database queries or using Node.js modules?
A lot of the answers to these questions are plain as day to see as an outsider:
VC dollars demand VC returns.
NextJS will continue to shepard react in a direction that benefits Vercel and pay big bucks to tech influencers like the mustache dude.
Walk away, there are better ways to build web apps today.
- leerob 2y agoMiddleware 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 https://github.com/vercel/next.js/pull/70961
- tommy_axle 2y agoGood to hear. Even with edge you can have a request that blocks or does something silly so IMO it should have had node from the beginning. A common use case is verifying a session or authorization for an entire area.
- leerob 2y agoUnfortunately, that's an anti-pattern here if you are making a request. If you're just checking cookies, then yes that makes sense. The documentation on auth for Next.js tries to make this clear, but my feeling is that "middleware" was a bad name and it came off like we were trying to do Express middleware 1:1.