Javascript Buy SDK, product.fetchAll is not working CORS Error

New Member
2 0 5

Today's date is July 4, 2019.

Yesterday I was working on a website using Shopify's Buy SDK to fetch all the products from Shopify (essentially a db). Everything was working fine yesterday, I was able to fetch all the products, product title, pricing, etc. But today as soon as i open my files and run my code, it runs into a CORS error. I tried retrieving a new access token but that doesn't seem to be the problem. I am able to initialize Shopify.buildClient and console it, but as soon as I try to fetch something it doesn't work.

 

The specific error i received was this:

 

"Access to fetch at 'https://name.myshopify.com/api/2019-07/graphql' from origin 'http://localhost:8080' 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."

5 Likes
New Member
1 0 0

I have the same issue, tried product.fetchAll() and it throws a CORS error trying to fetch:  https://{my-store}.myshopify.com/api/2019-07/graphql 

Have you found a solution?

0 Likes
New Member
1 0 0

I faced this same issue. Seems like a problem with their SDK. If you're using version 2.6.1, drop back to 2.6.0 and it should work.

0 Likes
New Member
2 0 5

Do you know if this effects production?

0 Likes
New Member
1 0 1

Same problem here. I spent the better part of Friday searching for solutions when I came across the SDK changelog on Github. It appears API versioning was released on July 3, so request URLs have been updated from .../api/graphql to .../api/{version}/graphql. Removing the version from the URL solved the CORS issue, even using SDK v2.6.1. I went into the index file and removed it manually, and will add again once Shopify has figured their issues out. Seems like they didn't test well enough before moving forward with this release. Maybe a middleware problem, who knows.

1 Like
New Member
2 0 0

Same issue here, replying for Shopify to get more visibility on issue and hopefully post a solution.

This issue is effecting production.

0 Likes
Highlighted
Community Manager
Community Manager
492 21 53

Hi folks,

 

Thanks for flagging this. We've identified the issue and have a fix ready to ship. I can update here once it has deployed.

 

In the meantime, as discussed here, dropping to v 2.6.0 or removing the version from the url should resolve the issue.

0 Likes