NEXTJS_NO_FETCH_IN_SERVER_PROPS

Prevent relative fetch calls in getServerSideProps from being added to Next.js applications.
Table of Contents

Conformance is available on Enterprise plans

Since both getServerSideProps and API routes run on the server, calling fetch on a non-relative URL will trigger an additional network request.

Instead of using fetch to make a call to the API route, you can instead share the code in a shared library or module to avoid another network request. You can then import this hared logic and call directly within your getServerSideProps function, avoiding additional network requests entirely.

Last updated on July 23, 2024