Edge Middleware
Answered
English Angora posted this in #help-forum
English AngoraOP
We are migrating our services from php to nextjs and middleware is a crucial thing for us.
But edge middleware is too pricey since only 1m invocations are free in pro plan.
Can we close the edge and use ssr instead of edge? Thank you
But edge middleware is too pricey since only 1m invocations are free in pro plan.
Can we close the edge and use ssr instead of edge? Thank you
Answered by joulev
But all of this discussion is not necessary since it’s just impossible to opt out of the edge runtime for middleware
17 Replies
English AngoraOP
You can imagine that we use something like vercel platforms/medium/hashnode
We use domain of a user
If you have enough users to reach that limit, I believe you do have enough revenue to use more than a free plan
But if you do reach that limit and don’t want to use paid vercel plans, you will need to self host or choose a different hosting provider
English AngoraOP
We want to use vercel, but we don't need an edge network. Looking for a way if we can remove it.
You cannot opt out of edge runtime in middleware
English AngoraOP
For Middleware specifically
Vercel is serverless, if you opt out of edge your middleware and hence your entire app will be plagued by things like cold boot
Making middleware non-edge makes sense if you self host; but doesn’t make sense in serverless; you have to use the edge if you don’t want your app to be horribly slow
But all of this discussion is not necessary since it’s just impossible to opt out of the edge runtime for middleware
Answer
Even if you use tricks like fetching a nodejs serverless function in middleware, it is still counted towards your edge invocation limit
@joulev Even if you use tricks like fetching a nodejs serverless function in middleware, it is still counted towards your edge invocation limit
English AngoraOP
Oh, so if we use orm like prisma in middleware does it counts as edge invocation?
@English Angora Oh, so if we use orm like prisma in middleware does it counts as edge invocation?
One middleware trigger is an edge invocation regardless of what you use in it
Btw you cannot use prisma in the edge unless you use a proxy like the prisma proxy
English AngoraOP
We use api folder to access the orm, fetch in middleware
Yes it is still counted towards the invocation limit
@joulev If you have enough users to reach that limit, I believe you do have enough revenue to use more than a free plan
English AngoraOP
Well thank you anyway! I got my answer and will try to optimize or change our price plan for users