3

I'm creating an LWC to be embedded in a Visualforce page to be shown in a Public Force.com Site following the documentation:

https://developer.salesforce.com/docs/component-library/documentation/en/48.0/lwc/lwc.use_visualforce

However the component doesn't load and the Javascript Console indicates the following error

{
    "event": {
        "descriptor": "markup://aura:invalidSession",
        "attributes": {
            "values": {}
        },
        "eventDef": {
            "descriptor": "markup://aura:invalidSession",
            "t": "APPLICATION",
            "xs": "I",
            "a": {
                "newToken": ["newToken", "aura://String", "I", false]
            }
        }
    },
    "exceptionEvent": true
}

Maybe I'm missing something or is directly not possible to use LWC embedded in Visualforce in Public Sites since there's not a real existing session.


Visualforce

    <apex:includeLightning/>

    <div id="lightningvf" />

    <apex:outputPanel layout="none" rendered="{!individualId != null}">
        <script>
            $Lightning.use("c:myLwcCompAuraApp", function() {
                $Lightning.createComponent("c:myLwcComp",
                    { recordId : "{!contactId}" },
                    "lightningvf",
                    function(component) {}
                );
            });
        </script>
    </apex:outputPanel>
</apex:page>

Aura App

<aura:application access="GLOBAL" extends="ltng:outApp"> 
    <aura:dependency resource="c:myLwcComp"/>
</aura:application>

LWC

HTML

<template>
    test
</template>

JS

import { LightningElement, api } from 'lwc';

export default class MyLwcComp extends LightningElement {
    @api recordId;
}
3
  • Seems like you've done everything right... maybe simplify even further by testing using a standard component like in the example and perhaps removing the output panel? Commented Mar 2, 2020 at 17:45
  • Same error shows up when firing an apex imperative call from callback of an streaming api subscription. https://salesforce.stackexchange.com/questions/314515/lwc-apex-from-emp-api-callback-firing-dispatch-event-or-an-apex-call-from-st. @jonathanwiesel Did you get any answer for this. Commented Aug 2, 2020 at 9:55
  • 1
    @NagendraSingh I'm afraid not =(, I've abandoned thw approach Commented Aug 2, 2020 at 18:46

1 Answer 1

3

I had a exactly same issue... And I solved it including ltng:allowGuestAccess in Aura App. Like this:

<aura:application extends="ltng:outApp" implements="ltng:allowGuestAccess" access="GLOBAL">
    <aura:dependency resource="MyLWC" />
</aura:application>
1

You must log in to answer this question.

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