admin管理员组

文章数量:1405392

I am trying fetch data from weather API by using a Lightning Web Component (LWC) but getting "Can't Access Resources" error every time it is sending a request through the component in Salesforce Experience site.

I have added the URL in "Trusted URLs" object in the Developer Edition Org.

In Experience builder > Settings > Security & Privacy, I have added the API URL in "Trusted Sites for Scripts" as well.

My user profile i.e. System administrator is API Enabled as well.

But still getting the below error (Image attached), Has anyone faced the same issue??

Can't Access Resources

Access to resources from an unapproved, external host violates the Content Security Policy (CSP). To allow access to these resources, add the host to the list of trusted hosts in Trusted URLs in Salesforce Setup. More Details

Blocked URI: .5/weather?q=London&units=metric&appid=API_KEY
CSP directive: connect-src

I am trying fetch data from weather API by using a Lightning Web Component (LWC) but getting "Can't Access Resources" error every time it is sending a request through the component in Salesforce Experience site.

I have added the URL in "Trusted URLs" object in the Developer Edition Org.

In Experience builder > Settings > Security & Privacy, I have added the API URL in "Trusted Sites for Scripts" as well.

My user profile i.e. System administrator is API Enabled as well.

But still getting the below error (Image attached), Has anyone faced the same issue??

Can't Access Resources

Access to resources from an unapproved, external host violates the Content Security Policy (CSP). To allow access to these resources, add the host to the list of trusted hosts in Trusted URLs in Salesforce Setup. More Details

Blocked URI: https://api.openweathermap./data/2.5/weather?q=London&units=metric&appid=API_KEY
CSP directive: connect-src
Share Improve this question asked Mar 22 at 7:51 Abhinav KashyapAbhinav Kashyap 12 bronze badges 1
  • Shorten your text, show the code you are using. – Cymro Commented Mar 29 at 9:25
Add a comment  | 

1 Answer 1

Reset to default 0

Today I made some changes and was able to fetch the data successfully.

What changes I made?

1. Add the site "https://api.openweathermap." in Setup > Security > Remote Site Settings.

2. Add the site in Setup > Trusted URLs and also Enable the CSP directive "connect-src (scripts)"

本文标签: Salesforce experience site quotCant access resourcesquot error while fetching data from APIStack Overflow