Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DynamicServerError at build time when cache: no-store is enabled #339

Open
mpotane opened this issue Aug 4, 2024 · 1 comment
Open

DynamicServerError at build time when cache: no-store is enabled #339

mpotane opened this issue Aug 4, 2024 · 1 comment

Comments

@mpotane
Copy link

mpotane commented Aug 4, 2024

export const { query } = registerApolloClient(() => {
  return new ApolloClient({
    cache: new InMemoryCache(),
    link: new HttpLink({
      uri: "https://api.github.com/graphql",
      // you can disable result caching here if you want to
      // (this does not work if you are rendering your page with `export const dynamic = "force-static"`)
      fetchOptions: { cache: "no-store" }, // --enabled
      headers: {
        authorization: `Bearer ${process.env.GITHUB_TOKEN}`,
      },
    }),
  });
});
@phryneas
Copy link
Member

phryneas commented Aug 5, 2024

Hi Mark,
could you please add a little bit more explanation?

Generally, if you force your page to be generated statically and then make a dynamic request like this, Next.js will error, as these two modes cannot exist at the same time.

I assume that's what's happening here - but with more context I can't help you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants