Next.js Discord

Discord Forum

Using the Node.js runtime for middleware

Answered
Pollock posted this in #help-forum
Open in Discord
PollockOP
As the title says, is there a way (or workaround) to use the Node.js runtime instead of the Edge runtime for middleware? This project won't be running on Vercel and will be self-hosted
Answered by joulev
It’s still the edge runtime unfortunately. Unpopular design decision and I heard they are planning to support nodejs in middleware for self hosting
View full answer

4 Replies

@Pollock As the title says, is there a way (or workaround) to use the Node.js runtime instead of the Edge runtime for middleware? This project won't be running on Vercel and will be self-hosted
Sloth bear
I'm not sure but if it is self hosted shouldn't the middleware use the node runtime the whole application is using?
@Sloth bear I'm not sure but if it is self hosted shouldn't the middleware use the node runtime the whole application is using?
It’s still the edge runtime unfortunately. Unpopular design decision and I heard they are planning to support nodejs in middleware for self hosting
Answer
@joulev Way, no. Workaround: make an api route, move nodejs logic to there and fetch that api route inside middleware
PollockOP
Yeah, I ended up doing something like this, thank you