Next.js Discord

Discord Forum

How can i run code for all specified routes without making a middleware.js file

Unanswered
Arboreal ant posted this in #help-forum
Open in Discord
Arboreal antOP
So the reason i cant use a middleware.js file is because i cant query the database and in my use case thats required, Im making an account suspended ui that will show on all routes except the homepage, this ui would show stuff like the suspenssion reason, date etc

5 Replies

Arboreal antOP
bump
Himalayan
Why wouldnt you be able to use middleware to query the database?
@Himalayan Why wouldnt you be able to use middleware to query the database?
Arboreal antOP
because ⨯ Error: The edge runtime does not support Node.js 'net' module.
Himalayan
Ah havent used edge runtime maybe its possible within a layout file?
@Himalayan Ah havent used edge runtime maybe its possible within a layout file?
Arboreal antOP
oh didnt think of that, that should work