I have built a dependency app using extends="ltng:outApp"
that is hosted on heroku. It runs on an express node.js server and I use salesforce-oauth2-flow
. Lets call it myApp
myApp is whitelisted in CORS settings as https://myApp.herokuapp.com and it loads fine and is fully functional with Locker Service disabled and Locker Service enabled, too, except one: myApp references a static resource.
For that I use
ltng:require scripts="<ltng:require scripts="{!'https://my-instance.lightning.force.com'+$Resource.customResource}"
afterScriptsLoaded="{!c.onLoaded}" />"
After turning Locker Service on, the component works fine in my own developer org.
Authentication, loading and displaying the component does also work on heroku.
But with Locker Service on I fail to load the static resource referenced within the component:
XMLHttpRequest cannot load https://my-instance.lightning.force.com/resource/1484XXXX0000/customResource.
No 'Access-Control-Allow-Origin' header is present on the requested resource.
Origin 'https://myApp.herokuapp.com' is therefore not allowed access.
How can I load the static resource successfully in this context?
https://my-instance.lightning.force.com
or simply use/resource/xyz/abc.js
in the scripts variable (that worked for me and I did not need to add to CORS)<ltng:require scripts="{!$Resource.customResource}" afterScriptsLoaded="{!c.onLoaded}" />"
$Resource
purely or a relative path results in heroku trying to load the resource locally - which results in 404.