I want to use my LWC'in an External Site (Heroku). For it I use Lightning Out.
I have built a simple Aura Application (in my Sandbox) according to documentation here : Lightning Out Dependencies
<aura:application access="Global" extends="ltng:outApp" >
<aura:dependency resource="c:testLWC"/>
</aura:application>
I have implemented the OAuth using JWT auth (based on this great video : Implementing a JWT Server to Server OAuth between Salesforce and Heroku ).
The main method (which connects to Lightning Out) in the Heroku :
let renderLightningOutComponent = (token) => {
$Lightning.use(
"c:LightningOutDemo",
function() {
$Lightning.createComponent(
"c:testLWC",
{},
"testLWC",
function(cmp) { /* ToDo */}
);
},
"https://{my-domain}.lightning.force.com",
token
)
};
-- ERROR --
If my user is NOT logged in Salesforce, I get next errors in JS Console :
And the Network :
It works without the problems if a users is logged in !
So as I understand the $Lightning.use()
method fails for some reason when a user is not logged in the Sandbox.
As I see it tries to load some resource as app.css, aura_prod.js etc.
IMPORTANT :
I do NOT have this issue if I try to connect to my Developer org .
Is there is something that I am missing ?
Any help will be appreciated.
Thank you.