In connected mode, when I try preview\browse a page in Sitecore, I'm getting the below CORS error. I've CORS setting as '*' in the API key.

Alternatively, I tried removing the CORS entry in API key and enabled in web.config as below. Still no luck. Any clue as to what's going wrong here

    <add name="Access-Control-Allow-Origin" value="*"/>
            <add name="Access-Control-Allow-Methods" value="GET,PUT,POST,DELETE,OPTIONS"/>
            <add name="Access-Control-Allow-Headers" value="Content-Type"/>

enter image description here

  1. Check that your layoutServiceHost is correct in scjssconfig.json.

  2. Do you get a 200 response when browsing to <layoutServiceHost>/sitecore/api/layout/render/jss?item=/&sc_apikey=<apiKey>

    If not then check that you've followed all the steps in getting-started

  • I don't see any issues with the layout service url. It returns 200 response for the item. Key factor to mention is that the page\item is internally calling a third party API to fetch the data for some of the fields. And that's when CORS error is being encountered. But as said, API key has CORS enabled for all these urls. Is there any other settings to be enabled\disabled? – voodem Feb 5 at 23:41
  • If you open up the network tab in dev tools, is it the fetch from the third party API that's being blocked by CORS? – Pirate Briggs Feb 6 at 11:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.