Assuming that you are getting this error with a Headless SXA site and wish to use the nextjs-multisite
add-on, do not set the rootItemId
for the GraphQLDictionaryService
as the service will only resolve one of your sites. Instead do one of the following:
Only using Headless SXA sites
If your app is only going to be used with Headless SXA sites, update the GraphQLDictionaryService
configuration in src\lib\dictionary-service-factory.ts
with jssAppTemplateId: '9ed6640464c9412290e1869cb3cea566',
as follows:
return new GraphQLDictionaryService({
endpoint: config.graphQLEndpoint,
apiKey: config.sitecoreApiKey,
siteName,
jssAppTemplateId: '9ed6640464c9412290e1869cb3cea566', // SXA "Headless Site" template ID
/*
The Dictionary Service needs a root item ID in order to fetch dictionary phrases for the current
app. If your Sitecore instance only has 1 JSS App, you can specify the root item ID here;
otherwise, the service will attempt to figure out the root item for the current JSS App using GraphQL and app name.
rootItemId: '{GUID}'
*/
})
Using both Headless SXA sites and "vanilla" Headless Services sites
If your app is going to be used for both Headless SXA sites and "vanilla" Headless Services sites, add the Headless Services App
template (/sitecore/templates/Foundation/JavaScript Services/App
) as a base template to the Headless SXA Headless Site
template (/sitecore/templates/Foundation/JSS Experience Accelerator/Multisite/Headless Site
).
This is the approach that the XM Cloud team has taken if you'd like to implement the "official" fix. This will of course require you to serialize and track the Headless Site
template in your code repository.
Analysis
For analysis of this, see this issue on GitHub: https://github.com/Sitecore/jss/issues/1556.