首页 > 解决方案 > 加载 apex iframe 时出现内容安全策略错误

问题描述

问题:我们的 Visualforce 页面集成出现 CSP(内容安全策略)错误。

问题是当我们在沙盒测试中访问它时,我们发现我们的内容被包装在一个 iframe 中,并且该 iframe 也包含一个 iframe。

外部 iframe 似乎没有 URL,因此我们无法将其从 CSP 白名单中排除。

apex 将 iframe 动态地放入另一个没有任何 src 的 iframe 中,这就是为什么我们无法将可以打开我们网站的域列入 iframe 的白名单。

<iframe allow="geolocation *; microphone *; camera *" frameborder="no" height="1000px" id="0661b0000004nmw" marginheight="0" marginwidth="0" name="0661b0000004nmw" scrolling="yes" title="HelloWorld" width="100%">
  <iframe src="https://example.com"> </iframe>
</iframe>
[Report Only] Refused to display 'https://example.com' in a frame because an ancestor violates the following Content Security Policy directive: "frame-ancestors 'self' *.salesforce.com".

请让我知道在这种情况下是否有解决内容安全错误的方法!

标签: iframesalesforcecontent-security-policysalesforce-lightning

解决方案


推荐阅读