Build fails because Routes API fetch call is made on an SSR page that is offline
Answered
Ichneumonid wasp posted this in #help-forum
Ichneumonid waspOP
For my Next.js app (using the App router), my local production builds successfully when the backend server that my Next.js app makes fetch calls to is running. However, when the backend is not running, it fails. Is there some sort of solution, in code, to where it should be able to build successfully regardless if my backend server is running or not?
Answered by joulev
export const revalidate = 0 to opt out of static rendering should fix it (your backend only needs to be running when the nextjs app is running)4 Replies
@Ichneumonid wasp For my Next.js app (using the App router), my local production builds successfully when the backend server that my Next.js app makes fetch calls to is running. However, when the backend is not running, it fails. Is there some sort of solution, in code, to where it should be able to build successfully regardless if my backend server is running or not?
export const revalidate = 0 to opt out of static rendering should fix it (your backend only needs to be running when the nextjs app is running)Answer
Ichneumonid waspOP
error^^ for reference
disregard previous message @joulev , googled that that code should be on my route.ts file and not the page that invokes the API route
awesome, works! thank you @joulev