function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Dhaker HassineDhaker Hassine 

VF page not working as a website home page

Hello everyone! 

I createf a VF page, it works when I put preview, but when I put it as my website home page, it doesn't work. 

What must be the problem here? 


This is what it looks like when I overview my website home page:
User-added image
But when I put any other VF page as a home page, it works normally 

Best Answer chosen by Dhaker Hassine
Dhaker HassineDhaker Hassine

Hello! I manage to solve it by following this steps : 

You should be sure about all objects and pages and classes are added to Site Public Access Settings.
On Setup \ Sites > click label of your site on the list.
Your site page opens, and click "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: Dont add your component inside apex:form it causes dropdown menus to refresh all pages when click to open.

Thanks for efirat! source:  https://salesforce.stackexchange.com/questions/178761/exposing-lightning-app-on-force-com-sites

 

Thank you Anudeep as well for your help 

All Answers

AnudeepAnudeep (Salesforce Developers) 
Hi Dhaker, 

Do you see any error in the network tools (browser console)? There could be issues with iframe (Certain X-Frame-Options header could stop embedding the site in a frame)

What does your VF page look like and do you see any specific differences when you compare both the pages?
 
Dhaker HassineDhaker Hassine
This is what the browser console look like: 
User-added image 
and for my VF page, it's a lightning component call inside! 
this is VF page code: 
<apex:page sidebar="false" showHeader="true" standardStylesheets="false" >
    <apex:includeLightning />

    <div id="signInDiv"></div>

    <script>
        $Lightning.use("c:testApp", function() {
            $Lightning.createComponent("c:MainComponent",
                    {},
                    "signInDiv",
                    function(cmp) {
                        console.log('>>>>> App is hosted');
                    });
        });
    </script>
</apex:page>

and this is the lightning component code :
<aura:component access="global" implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,forceCommunity:availableForAllPageTypes" >
    <aura:attribute name="variable" type="boolean" default="False"/>
    <aura:attribute name ="login" type="string" default =''/>
   <aura:handler name="connResource" event="c:LoginEvent" action="{!c.handleLoginEvent}"/>
	 <aura:if isTrue="{!v.variable == False}">
         <c:SignIn/>
         
    <aura:set attribute="else">
        
      <c:Calend childAttribute="{!v.login}"/>
        

       <c:Calend/>
       
    </aura:set>
  </aura:if> 
</aura:component>


 
Dhaker HassineDhaker Hassine

Hi Anudeep; 

Do you have any idea to solve this problem?

AnudeepAnudeep (Salesforce Developers) 
Hi Dhaker, 

Does your testApp look like this? 
<aura:application access="GLOBAL" extends="ltng:outApp">
	<aura:dependency resource="c:MainComponent"/>
</aura:application>
My suggestion would be to try replacing the app and component with any another app/component in your org to narrow this down 

$Lightning.use("c:testApp", function() {

Also ensure your VF page is "Available for Lightning Experience, Lightning Communities, and the mobile app".

Anudeep

 
Dhaker HassineDhaker Hassine

Hello! I manage to solve it by following this steps : 

You should be sure about all objects and pages and classes are added to Site Public Access Settings.
On Setup \ Sites > click label of your site on the list.
Your site page opens, and click "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: Dont add your component inside apex:form it causes dropdown menus to refresh all pages when click to open.

Thanks for efirat! source:  https://salesforce.stackexchange.com/questions/178761/exposing-lightning-app-on-force-com-sites

 

Thank you Anudeep as well for your help 

This was selected as the best answer