1

When we build nextJs yarn build when it goes to the step Generating static pages we have this error:

Error occurred prerendering page "/partners/partner-with-us". Read more: https://nextjs.org/docs/messages/prerender-error
ApolloError: Dynamic server usage: Route /partners/partner-with-us couldn't be rendered statically because it used revalidate: 0 fetch http://localhost:4001 /partners/partner-with-us. See more info here: https://nextjs.org/docs/messages/dynamic-server-error

The page partner-with-us is super simple


const PartnerWithUs = () => {
  return <>test</>
}

export default PartnerWithUs

We are using Apollo Graphql for fetching data on other pages. We are using: https://github.com/apollographql/apollo-client-nextjs?tab=readme-ov-file#in-client-components-and-streaming-ssr

in the main layout we have

<ApolloWrapper>
  <main>{children}</main>
</ApolloWrapper>

Questions I am trying to solve to fix this issue:

  • why is he trying to get to the backend for this page partners/partner-with-us ? it is just a basic html page
  • is he trying to access http://localhost:4001 /partners/partner-with-us? :4001 is the url of the backend, (frontend is :4022)
  • be rendered statically because it used revalidate: 0 where is this settings?
  • it says ApolloError: Dynamic server usage it is an apollo (GrpahQl) error?

1 Answer 1

1

My problem resulting in "revalidate: 0 fetch" error was that I was fetching data without caching enabled.

const res = await fetch(`${this.baseUrl}/items/${entity}`, {
    method: 'GET',
    headers: this.getHeaders(),
    cache: 'force-cache', // cache on for static generation
    // cache: 'no-store', // cache off
});

My guess is that when no caching mechanism is assured, then SSR breaks, skipping the build step.

Not sure how apollo client can be configured to enable caching, but I would try looking.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.