NO_FETCH_FROM_MIDDLEWARE
Conformance is available on Enterprise plans
Next.js middleware runs code at the Edge. This means that the code is globally distributed. When middleware makes a call, it may be to a backend that is not globally distributed, in which case the latency of the middleware function will be really slow. To prevent this, calls that can be made from middleware are flagged and reviewed to make sure that it looks like an appropriate use.
This check will fail when a call is detected from Next.js middleware or transitive dependencies used by the middleware file.
In this example, there are two files. An experiments file asynchronously fetches experiments using . The middleware file uses the experiments library to fetch the experiments and then decide to rewrite the URL.
The correct fix will depend on the specific situation. If the server that is being called is globally distributed, then this asynchronous call may be okay. If not, then the code should try to remove the statement to avoid making a request that would add latency to middleware.
Was this helpful?