[SalesForce] lightning:Map component not loading in communities after Spring 19

I have created a lightning component which host the code for lightning:Map. The component is loading fine in Salesforce but in Communities, I am having the following error:

Access to resources from an unapproved, external host violates your
Content Security Policy (CSP). To get access to these resources, try
whitelisting the host in CSP Trusted Sites in Salesforce Setup. More
Details

Blocked URI:
https://5e7f3496-9b88-3b86-7d4a-7fd47535be70.a.forceusercontent.com
CSP directive: frame-src

I tried to whitelist the url but the thing is that each time the component is being reloaded, the hash in the url changes.

Has anyone got a workaround on how to load the lightning:Map component without this error message.

enter image description here

The component code is exactly as in the Salesforce Documentation. We have not changed anything and works fine in Salesforce environment but not on community.
lightning:Map source code example

Best Answer

I fixed it by including a "Content Security Policy Trusted Site" with the domain displayed in the error message. In my case the domain is always the same one "https://maps.a.forceusercontent.com".

Go to Setup > CSP Trusted Sites. And click on "New Trusted Site".

Tis is how should be created:

enter image description here

Hope that helps!

Related Topic