Skip to main content

Hi everyone, 

 

I’m working on a simple Lightning Web Component that contains a list of external reading resources. The links work normally when I copy them into Chrome, but I’m having trouble when I try to open them directly from the LWC. 

 

For example, I added a reference link for the Surah Baqarah Last 2 Ayat resource

. When I click the link from the component, the behavior is inconsistent depending on how the link is opened. 

 

I’m currently using a standard anchor element and have also tried NavigationMixin with standard__webPage. 

 

Is there a recommended Salesforce approach for opening an external HTTPS website from an LWC? Do I need to add the domain under Trusted URLs/CSP settings, or should an external website simply be opened in a new browser tab without any CSP configuration? 

 

Any example of the recommended implementation would be appreciated. 

 

#Security

2 answers
  1. Sep 23, 6:35 AM

     Hi Kevin, 

     for opening an external website from an LWC, you don't need any CSP/Trusted URL configuration that's only required when the LWC needs to call an external endpoint or load a remote resource . Simply navigating the user's browser to an external URL in a new tab is just standard browser navigation and Salesforce doesn't mediate it. you can use a plain anchor tag with rel="noopener noreferrer". 

      

     I hope this help!!

0/9000