JS Buy SDK CORS error

stenda
New Member
1 0 0

Hi everyone,

I'm trying to integrate the JS Buy SDK to add some custom "buy button" into my client institutional website but I'm facing this CORS error that tells that accept-language header is not allowed by the Access-Control-Allow-Headers of the response (sorry the message below it's in italian):

Bloccata richiesta multiorigine (cross-origin): il criterio di corrispondenza dell’origine non consente la lettura della risorsa remota da https://xxx.myshopify.com/api/2020-07/graphql . Motivo: l’header “accept-language” non è consentito a causa dell’header “Access-Control-Allow-Headers” nella risposta CORS preliminare (“preflight”)

 

Hi Class TOP 65 è l’erogatore d’acqua frizzante di Cosmetal. – Mozilla Firefox 2021-01-03 10.30.49.png

 
 

Hi Class TOP 65 è l’erogatore d’acqua frizzante di Cosmetal. – Mozilla Firefox 2021-01-03 10.29.22.png

I'm using this script inclusion:

 

 

<script src="https://sdks.shopifycdn.com/js-buy-sdk/v2/latest/index.umd.min.js"></script>

 

 

and this js call:

 

 

client = ShopifyClientFactory.buildClient({
        domain: 'xxx.myshopify.com',
        storefrontAccessToken: 'xxx',
        language: 'it_IT'
      });

    

      client.product.fetchAll().then(...)

 

 

 

 

it seems that the initialization parameter 'language' cause this CORS error, but it shouldn't, probably the 2020-07 graphql version are not updated to support such header?

 

 

0 Likes
_JCC_
Shopify Staff
Shopify Staff
158 21 27

@stenda ,

Happy to help you out with this issue.

In my testing it looks like it_IT is an invalid value for Accept-Language header. Values of it, IT, it-IT, IT-IT all work for the language property when calling buildClient .

Hope this helps.

Regards,

John

John C | Developer Support @ Shopify 
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Mark it as an Accepted Solution
 - To learn more visit Shopify.dev or the Shopify Web Design and Development Blog

0 Likes