gpt4 book ai didi

Make Requests to products.json from Shopify Public App(从Shopify公共应用程序向products.json发出请求)

转载 作者:bug小助手 更新时间:2023-10-28 09:46:34 24 4
gpt4 key购买 nike



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.

我有一个公共应用程序,人们可以添加到他们的Shopify商店。当他们添加应用程序时,我会获得身份验证令牌,以便能够向他们的商店发出请求,以便在我的应用程序中展示他们的产品。我实际上可以使用PHP发出这个请求,但是,如果我使用JS执行相同的请求,我会被CORS阻塞。


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.

我试过添加模式:‘no-cors’,但他们只给了我401分。这是正在发生的事情的图表。我想在/getProducts页面上展示他们的产品。这是一张系统图。当这个API调用开始时,它们位于app.beta.com/getProducts上,并且它调用alpha.myshop ify.com/admin/Products.json我的头文件是正确的“X-Shopify-Access-Token”,因为这个令牌用于通过PHP进行的完全相同的API调用。


更多回答
优秀答案推荐

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.

现在的解决方案是创建一个php页面来请求Shopify,然后在Display Products页面上向我的php页面发出请求。为什么CORS讨厌JavaScript?可能是因为标题对每个人都可见。


更多回答

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com