While running my react based JSS app, I am getting an exception related to CORS. Below is the request. I am passing the sc_apikey and in the API key item cors, origin and Allowed Controllers fields have value *.

The Sitecore instance is based on SXA Headless Site and the version is 10.2

Access to XMLHttpRequest at
from origin 'http://localhost:3000' has been blocked by CORS policy:
Request header field sc_apikey is not allowed by
Access-Control-Allow-Headers in preflight response.

GraphQL is working which I verified from GraphQL UI.

  • Is your host running locally?
    – Richard Seal
    Commented Oct 14, 2022 at 15:03
  • In my case publishing API Key item from Master to Web resolved the error
    – shlk
    Commented Nov 28, 2023 at 16:43

3 Answers 3


Configuring CORS Sitecore provides CORS support for Web API services. It applies to all custom Web API services as well as the ones provided by Sitecore (for example the Item Service and the OData Item Service).

You can configure CORS in three ways:

  1. Globally for all Web API services (configured in the Sitecore.Services.Client.config file).

  2. Using an API key.

  3. Using the EnableCors attribute.

Global configuration The Sitecore.Services.Client.config file has a section called allowedOrigins. You register origins in this section. You do not have to provide an API key in requests to enable CORS, but origins that are registered via an API key or the EnableCors attribute take precedence over the ones that registered globally.

You add allowed origins similar to this:


<allowedOrigins hint="list:AddOrigin">

Using an API key If you configure a service to use an API key, Sitecore resolves the allowed origins from this key, provided in the request.

You specify the allowed origins in the CORS Origins field of an API key item.

Note The OData Item Service is configured to use API keys and can get allowed origins from them.

Using the EnableCors attribute You can enable CORS by adding the EnableCors attribute (from the System.Web.Http.Cors namespace) to a controller class and specifying the origins, headers, and methods parameters as needed.

For example, this controller has wildcard values for all of the resource restriction parameters:


[ServicesController][EnableCors(origins: "*", headers: "*", methods: "*")]public class TestController : ServicesApiController { ... }

In production environments, you must use a more restrictive definition of what can access resources.

More information can be found in Documentation.

  • 2
    I am trying all the options also tried above mention options but it's not yet resolved. Trying other options will update if worked.
    – Deb
    Commented Oct 18, 2022 at 15:03

I was integrating 3rd party App with my Sitecore and I resolved the CORS by adding this in my webconfig

<?xml version="1.0" encoding="utf-8"?> 
     <cors enabled="true">
       <add origin="https://frontendabc.sitecore.local">
             <add method="GET" />
             <add method="HEAD" />
       <add origin="https://frontendxyz.sitecore.local">
             <add method="GET" />
             <add method="HEAD" />
             <add method="POST" />
             <add method="PUT" /> 
             <add method="DELETE" />         

P.S. you can add origin="*"

For more https://darjimaulik.wordpress.com/2021/01/26/cors-error-in-sitecore-jss/


This patched worked for me.

<?xml version="1.0" encoding="utf-8" ?>
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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