Apoptosome
Apoptosome

Reputation: 23

Make Requests to products.json from Shopify Public App

I have a Public App people can add to their Shopify store. When they add the app, I get the authentication token to be able to make requests to their store to display their products in my app. I can actually make this request using PHP, however if I use JS to do the same request I get CORS blocked.

I have tried adding mode: 'no-cors', but they just give me a 401. Here is the diagram that is what's going on here. I want to display their products on the /getProducts page. Here's a System Diagram. When this api call goes off, they are sitting on app.beta.com/getProducts, and its making a call to alpha.myshopify.com/admin/products.json My headers are the correct "X-Shopify-Access-Token", since this token works for the exact same API call through PHP.

Upvotes: 0

Views: 410

Answers (1)

Apoptosome
Apoptosome

Reputation: 23

The solution right now is making a php page to do the request to Shopify, and then on the display products page I make a request to my php page. Why does CORS hate JavaScript? Probably because the headers are visible to everyone.

Upvotes: 1

Related Questions