How to attone.lightning.force?

314    Asked by DavidEdmunds in Salesforce , Asked on May 9, 2023

I am struggling on how to expose lightning apps in force.com sites

As per one of the answers in this link I should be able to expose lightning apps on force.com sites :

Expose Lightning .app publicly?

I get a 500 error when the site accesses the lightning app. The same app renders fine on the visualforce page. What am I missing here? Is it even possible to expose a lightning app through a public site without authentication?

Lightning App:


        

VF Page used in force.com site:
 


[removed]
    $Lightning.use("c:Lightningappforsite", function() {
      $Lightning.createComponent("c:caseSearchcomponent",
      "",
      "lightning",
      function(cmp) {
        // do some stuff
      });
    });
[removed]

Output of component inside the VF Page:

Looking further in the console I see invalid session, looks like salesforce is expecting authentication to access the lightning component.

Console shows invalid session when i try to look at the raw request:

while(1); {"defaultHandler":"function(token) {try{$A.clientService.invalidSession(token);}catch(e){[removed].reload(true);}}","event":{"descriptor":"markup://aura:invalidSession","attributes":{"values":{}},"eventDef":{"descriptor":"markup://aura:invalidSession","type":"APPLICATION","xs":"I","superDef":{"descriptor":"markup://aura:applicationEvent"},"attributes":{"newToken":{"name":"newToken","type":"aura://String","xs":"I"}}}},"exceptionEvent":true}
Answered by David Edmunds

For attorney.lightning.force, you should be sure that all objects and pages and classes are added to Site Public Access Settings.


On Setup  Sites > click the label of your site on the list.
Your site page opens, and click the "Public Access Settings" button.

Here all permissions should be set. First edit and give permissions for all related objects, and then add your all related classes to Enabled Apex Class Access and add all related VF Pages to Enabled Visualforce Page Access list.

Then your component should work. Hint: Don't add your component inside apex:form it causes dropdown menus to refresh all pages when clicked to open.



Your Answer

Interviews

Parent Categories