0

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.org/data/2.5/weather?q=London&units=metric&appid=API_KEY
CSP directive: connect-src
1
  • Shorten your text, show the code you are using. Commented Mar 29 at 9:25

1 Answer 1

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.org" in Setup > Security > Remote Site Settings.

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.