0

I update the code to below and I can preview the page. But when I add the page to Lightning app builder, it cannot load. And got the error Refused to frame 'https://mirage-video-dev-ed--ltng.container.lightning.com/' because an ancestor violates the following Content Security Policy directive: "frame-ancestors https://mirage-video-dev-ed--c.visualforce.com".

<apex:page >
    <apex:includeLightning />
    <div id="hello" />
    <script>
        $Lightning.use("c:myFirstApp", function() {
            $Lightning.createComponent("lightning:container",
              { src: "{!$Resource.hello + '/index.html'}"},
              "hello",
              function(cmp) {
                console.log("button was created");
                // do some stuff
              }
          );

        });
    </script>
</apex:page>

My myFirstApp.app

<aura:application access="global"  extends="ltng:outApp">
   <aura:dependency resource="lightning:container"/>
</aura:application>
0

Two things are missing in this code. Application needs to have ltng:outApp extended and VF Page should have the code block(some div with ID) to embed the body.

Reference to official documentation - https://developer.salesforce.com/docs/atlas.en-us.lightning.meta/lightning/components_visualforce.htm

| improve this answer | |
  • thank you. It works now – Huy Nguyen Aug 4 at 11:27
  • but i encounter another problem. I updated the question – Huy Nguyen Aug 4 at 11:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.