I'm currently working to include my external js in aura component. So, i have included my external JS as static resource. but i'm getting the below exception.
Refused to load the script '...' because it violates the following Content Security Policy directive: "script-src 'self' 'nonce-...' chrome-extension: 'unsafe-inline' 'unsafe-eval'
I have added all the required sites in below modules.
- Cors
- Remote Site Settings
- CSP trusted sites.
Please guide me to handle this issue
My sample external JS code:
var contentURL= 'https://xxxxxx.xxxxxx.xxxxxx.xxxxxx';
var serverUrl = 'https://xxxxxx.xxxxxx.xxxxxx';
var hostedJsUrl = 'https://xxxxxx.xx.xxxx.xxx';
var hostedJsPath = 'https://client.qa.xxxxxx.xxxxxx/qa/client-injected-latest';
var element = window.document.createElement('script');
element.setAttribute('id', 'letznav-script');
element.setAttribute('type', 'text/javascript');
element.setAttribute('data-server', serverUrl);
element.setAttribute('data-instanceid', tenantKey);
element.setAttribute('data-hosted-js', hostedJsUrl);
element.setAttribute('data-content-url', contentURL);
element.setAttribute('src', hostedJsPath + '/apty-client.js');
element.setAttribute('data-fonts-url', fontsUrl);
window.document.head.appendChild(element);
Locker Service Results:
<script>
element dynamically. Have you used Locker Service Console to evaluate this JS code?