Next.js Discord

Discord Forum

Next tries to fetch from internal API during build

Unanswered
Cinnamon posted this in #help-forum
Open in Discord
CinnamonOP
I think it does that to try to cache the requests and build static pages, but since our API is Next itself, while building it is offline and it throws a fetch failed error and the build fails.

One solution is to use export dynamc force-dynamic but that will opt out of caching the fetch requests, which isn't what we want.

Another option is to have dev running while doing build, so it can do the fetch requests.

But that doesn't sound like the best solution?

What should we do? Or what are we doing wrong?

0 Replies