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
1 Answer
Reset to default 0Today 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 "Cant access resources" error while fetching data from API - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744322321a2600561.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论