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"/>

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) => {
        function() {
                function(cmp) { /* ToDo */}

-- ERROR --

If my user is NOT logged in Salesforce, I get next errors in JS Console :

enter image description here

And the Network :

enter image description here

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.

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.

  • Have you tried adding implements="ltng:allowGuestAccess" to you Aura component to check if unauthenticated users can log in? Commented Oct 6, 2022 at 6:59
  • @KostadinStoev thanks for the comment, Yes I did try it. No difference. Commented Oct 6, 2022 at 8:22

1 Answer 1


The issue is with Enhanced Domains. (https://help.salesforce.com/s/articleView?id=sf.domain_name_enhanced.htm&type=5)

Enabling enhanced domains adds a .sandbox. to the URL, which is causing a few problems with Lightning Out.

I recommend disabling Enhanced Domain in the Sandbox so you can use/test it.

Production and Dev Orgs don't have the .sandbox. part added to the URLs which is why it works correctly there.

  • Thank you, with enhanced domains turned off it works correct. Commented Oct 7, 2022 at 13:38

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .