This is likely caused by one of two issues:
- The API key is incorrectly configured (less likely given the symptoms)
- The Headless Services package is missing required configuration on the CD role. (most likely)
To ensure the API key is configured properly, the CORS Origins
and Allowed Controllers
fields should be set to: *
I'm making a big assumption that you are attempting this in an On-Prem or Azure PaaS environment and are not using containers.
To ensure that Headless Services are installed properly on your CD, you should be using the Sitecore Headless Services CD WDP for Sitecore XM
from the Sitecore downloads page
https://dev.sitecore.net/Downloads/Sitecore%20Headless%20Rendering/19x/Sitecore%20Headless%20Rendering%201900
If you haven't worked with Sitecore Web Deploy Packages (.scwdp
) before, they are compressed files that you can unpack and manually copy all of the assets from this package to the root of your CD website.
If neither of these two options work for you, take a look at your ShowConfig for the ContentDelivery role.
https://<CM Url>/sitecore/admin/showconfig.aspx?layer=Sitecore|Modules|Custom|Environment&role=ContentDelivery
Make sure that these pipelines are present:
<pipelines>
<initialize>
<processor type="Sitecore.LayoutService.Mvc.Pipelines.Initialize.RegisterRoutes, Sitecore.LayoutService.Mvc"
patch:before="processor[@type='Sitecore.Mvc.Pipelines.Loader.InitializeRoutes, Sitecore.Mvc']"
resolve="true" />
</initialize>
<httpRequestBegin>
<processor type="Sitecore.LayoutService.Mvc.Pipelines.HttpRequestBegin.SkipContextItemResolutionWhenLayoutServiceRequest, Sitecore.LayoutService.Mvc"
resolve="true"
patch:before="processor[contains(@type, 'ItemResolver')]"/>
</httpRequestBegin>
<mvc.requestBegin>
<processor type="Sitecore.LayoutService.Mvc.Pipelines.RequestBegin.ContextItemResolver, Sitecore.LayoutService.Mvc"
patch:after="processor[@type='Sitecore.Mvc.Pipelines.Request.RequestBegin.EnsureLoggedInForPreview, Sitecore.Mvc']"
resolve="true" />
</mvc.requestBegin>
</pipelines>
These are configured within the file: .\App_Config\Sitecore\LayoutService\Sitecore.LayoutService.Mvc.config
You can also quickly confirm whether Headless Server is installed correctly in ContentDelivery by checking the GraphQL playground using this url:
https://<CD Url>/sitecore/api/graph/edge/ui