Building Next.js-based JavaScript Services (JSS) applications connected to XM Cloud and Experience Edge might result in the following error:
ClientError: GraphQL Error (Code: 429):
{"response":{"error":"API calls quota exceeded!
maximum admitted 80 per
1s.","status":429,"headers":{}}
The issue occurs due to Next.js using multiple threads during static site generation, and therefore running multiple requests to GraphQL endpoint.
To resolve the issue, upgrade to Sitecore JSS 21.4.0 or later.
Alternatively, you can consider either one of the following options or their combination:
const nextConfig = {Follow the link to read more about this approach: nextjs GitHub discussions.
experimental: {
// This is experimental but can
// be enabled to allow parallel threads
// with nextjs automatic static generation
workerThreads: false,
cpus: 1
}
... }
constructor() {
this._graphqlSitemapService = new GraphQLSitemapService({
endpoint: config.graphQLEndpoint,
apiKey: config.sitecoreApiKey,
siteName: config.jssAppName,
pageSize: 100, //This line has to be added to set pageSize
});}