最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

Salesforce experience site "Cant access resources" error while fetching data from API - Stack Overflow

programmeradmin6浏览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: .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)"

发布评论

评论列表(0)

  1. 暂无评论