Can I run the new Next.js middleware in a self hosted environment? #30971
Unanswered
JonasHiltl
asked this question in
Help
Replies: 2 comments
-
|
You can run the new middleware in a self hosted environment, but they will have the same limits, i.e. no Node specific APIs. |
Beta Was this translation helpful? Give feedback.
0 replies
-
|
Is there any way to deploy the middleware as Cloudflare Workers? |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I'm building an applciation with
Next.jsthat is purely for authenticating the users through JWT's, and then redirecting them to our main web application. Before theNext.jsversion 12 release I have used next-connect to run one middleware function on every api request to deserialize the user from the token or refreshing the access token if the refresh token is expired. I now wanted to move fromnext-connectto the new api middleware but first of all I'm not sure how these functions would perform in an self hosted environment, because with Vercel they would be deployed as edge functions but how do they work in a self hosted environment? Just as normal express middleware or not at all?I also get the error
eval not allowed in Middleware pages/api/_middlewarebecause the standard jsonwebtoken package is not allowed in edge functions. This issue states that I would have to use the lightweight package@tsndr/cloudflare-worker-jwt, even though I'm not planing to use edge functions but rather deploy the app myself.This is the middleware I'm trying to run through the
_middlewarefile on every api request:Beta Was this translation helpful? Give feedback.
All reactions