admin管理员组文章数量:1292350
I am trying to call app proxy but getting error in dev tools -> Network Response body is not available to scripts (Reason: CORS Failed)
I have already tried setting my header as * as well as
headers: {
"Content-Type": "application/json",
'Access-Control-Allow-Origin': https://${storeDomain}.myshopify
,
}
url in my fetch is https://${storeDomain}/apps/my-subpath
and proxy url in app proxy is cloudflare tunnel with api/myfile.jsx ( which is accesible from my browser to ensure it is running)
Any idea what am I missing
I have already tried setting my header as * as well as
headers: {
"Content-Type": "application/json",
'Access-Control-Allow-Origin': https://${storeDomain}.myshopify
,
}
I am trying to call app proxy but getting error in dev tools -> Network Response body is not available to scripts (Reason: CORS Failed)
I have already tried setting my header as * as well as
headers: {
"Content-Type": "application/json",
'Access-Control-Allow-Origin': https://${storeDomain}.myshopify
,
}
url in my fetch is https://${storeDomain}/apps/my-subpath
and proxy url in app proxy is cloudflare tunnel with api/myfile.jsx ( which is accesible from my browser to ensure it is running)
Any idea what am I missing
I have already tried setting my header as * as well as
headers: {
"Content-Type": "application/json",
'Access-Control-Allow-Origin': https://${storeDomain}.myshopify
,
}
- Please provide enough code so others can better understand or reproduce the problem. – Community Bot Commented Feb 13 at 8:48
1 Answer
Reset to default 0Solution for the CORS issue in your Shopify App Proxy:
On your backend (API) server, add these CORS headers:
app.use((req, res, next) => { res.header('Access-Control-Allow-Origin', '*'); res.header('Access-Control-Allow-Methods', 'GET, POST, PUT, DELETE, OPTIONS'); res.header('Access-Control-Allow-Headers', 'Content-Type, Authorization'); if (req.method === 'OPTIONS') { return res.status(200).end(); } next(); });
In your frontend fetch request, remove the Access-Control-Allow-Origin header (it should only be set server-side):
fetch(
https://${storeDomain}/apps/my-subpath
, { method: 'GET', credentials: 'include', headers: { 'Content-Type': 'application/json' } })
本文标签: Getting error CORS failed in my Shopify App ProxyStack Overflow
版权声明:本文标题:Getting error CORS failed in my Shopify App Proxy - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741554843a2385091.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论