Ajax-api blocked by CORS policy error

New Member
1 0 0

Dear Shopify's Administrator,
When I making requests from my website to connect to https://xxx.myshopify.com/cart.js ,
I get an error like below, can you guide me to solve this error?

Error messages:
Access to fetch at 'https://xxx.myshopify.com/cart.js' from origin my website has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.

I followed the documentation at the link: https://shopify.dev/docs/themes/ajax-api