首页 > 解决方案 > Chrome 策略指令(内容安全策略):拒绝加载脚本'https://www.paypal.com/sdk/js

问题描述

我有一个使用 Paypal 的反应应用程序。

在 index.html 我有

<script src="https://www.paypal.com/sdk/js?client-id=MYCLIENTID&commit=true&disable-funding=credit,card"></script>

在我的 index.html 文件中。我也在后端(节点js)有以下作为标题:

app.use(function(req, res, next) {
  res.setHeader('Content-Security-Policy', "script-src 'self' https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js https://www.paypal.com/");
  return next();

});

我也用过

https://www.paypal.com/sdk/js

乃至

https://www.paypal.com/sdk/js?client-id=MYCLIENTID&commit=true&disable-funding=credit,card

在标题上,但我仍然在 Chrome 上收到以下错误。

Mysite.com/:1 Refused to load the script 'https://www.paypal.com/sdk/js?client-id=MYCLIENTID&commit=true&disable-funding=credit,card' because it violates the following Content Security Policy directive: "script-src 'self' my policies links...". Note that 'script-src-elem' was not explicitly set, so 'script-src' is used as a fallback.

任何人都知道我如何在谷歌浏览器的政策中通过 PayPal?谢谢

标签: node.jsgoogle-chromepaypalheaderpolicy

解决方案


推荐阅读