Salesforce站点Site+社区Community常见安全问题总结

本文探讨了在Salesforce Community和Site中遇到的安全策略(CSP)限制问题,包括iframe嵌套外部链接不显示、第三方CSS/JS失效及资源链接不可用等。详细介绍了在Community上展示QRCode的具体场景与解决方案,以及如何正确配置CSPTrustedSites来规避限制。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

前言】:
本篇博客旨在总结这类问题:
1. 在Site/Community中使用Iframe嵌套外部链接,无法显示;
2. 在Community中使用第三方CSS/JS,无法生效;
3. 第三方无法正常使用Site/Community暴露的链接资源;

Community篇】:
1. Community无法加载QR Code Image Formula Field?
场景:需要在Community的Campaign上展示QR Code,Sales登入后就能获得独一无二的QR Code,用于捕获Lead;

QR API for free: https://api.qrserver.com/v1/create-qr-code/?margin=10&size=200x200&data=https://baidu.com

问题:Community无法显示图片,并报错如下:
Refused to load the image, because it violates the following Content Security Policy directive: "img-src 'self' data: blob:

方案配置CSP Trusted Sites

拓展在Builder的Security的CSP处添加QR Code API不会生效,这里特指Script.

Site篇】: