3

I am trying to use Lightning out to show a lightning app in a html page. Following is the code snippet in my html page -

$Lightning.use([AppName], function() {
    $Lightning.createComponent("[ComponentName]", {}, [iframe], function(cmp) {});
}, [InstanceURL], [OAuthKey]);

In the Lightning App, I create the application which 'extends="ltng:outApp"' and specify the dependency for the component as

<aura:dependency resource="[Component Name"/>

I could not get this to work as I get a 500 Server error for the Lightning app url- http://[domainname-sandbox].cs62.my.salesforce.com/c/[lightningApp].app?aura.format=JSON&aura.formatAdapter=LIGHTNING_OUT

Could anyone get Lightning out to work on a html page?

1 Answer 1

1

You will need to expose your html page to the internet for the lightning out to work .You will need a node application running on your local host with ssl certificate or your html hosted on cloud like heroku or Amazon S3 and then you will need a CORS setting for the url in your SFDC org .

The other alternative is you can expose a community page which is public and have the Lightning out work there .

Here are some of the links to help you with

NodeJs application

Lightning Out Dreamforce Talk

Lightning Out with community builder public pages and sites visualforce pages

2
  • Hi Mohit, Thank you for your response. The part I was missing is the callback url defined on the SFDC org. Your video and code were very helpful. So I could go past the authorization part. The url - https://{domainname}--{sandboxname}.cs62.my.salesforce.com/c/lcvfTest.app?aura.format=JSON&aura.formatAdapter=LIGHTNING_OUT returns Success. But the absoluteUrl property in the response of this call is blank. So the susequent resource.js file and the app.css files that should be loaded from the SFDC org are loading from the server where I hosted the html page. Any idea why this is happenning?
    – Karte
    Commented Apr 11, 2017 at 23:10
  • 1
    A bit old post but I just hit the same error - solved it by removing the instance name from the URL - the url sent should look like this = https://{domainname}--{sandboxname}.lightning.force.com ( remove cs62)
    – sfdx bomb
    Commented Jan 30, 2019 at 22:41

You must log in to answer this question.

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