违反以下内容安全策略指令:*** in Shopify

Violates the following Content Security Policy directive: *** in Shopify

我为 Shopify 制作了一个自定义应用程序。但是当我设置应用程序 AWS EC2 时出现以下错误。

Refused to frame 'https://***.com:2053/' because it violates the following Content Security Policy directive: "frame-src app.myshopify.io *.shopifyapps.com .myshopify.io .myshopify.com https:// shopify-pos://".

奇怪的是,当我在 EC2 上使用 Ngrok 时,它运行良好。另一方面,当我使用原始域时,它不起作用并且出现错误。我已经使用 Certbot 设置了 SSL。我确认直接连接到我的域,而不是通过 shopify 应用程序。我把它提到了这个网站:https://shopify.dev/tutorials/build-a-shopify-app-with-node-and-react.

我已经研究了一个星期了,但我没有解决它的线索。各位有没有相同的经历,知道怎么解决吗?

CSP 包括 https://。根据 the specification 这并不意味着在任意端口上使用 HTTPS,而只是在默认端口 443 上。

您的自定义应用程序改为使用 https://...:2053,它与允许的协议匹配但与允许的端口不匹配。使用 ngrok 时,协议和端口都匹配,因为 ngrok 使用默认端口 443。