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
Francesco DessìFrancesco Dessì 

X-Frame-Options = Deny

Hi,
In a Community page, I have an LWC whit a Visualforce page embedded with an Iframe.
Everything works fine, but when I load the page with Chrome in incognito mode I the get the error:

Refused to display 'https://……………' in a frame because it set 'X-Frame-Options' to 'deny'

and the visulaforce page does't appear.

Best Answer chosen by Francesco Dessì
Francesco DessìFrancesco Dessì

On salesforce.stackexchange (https://salesforce.stackexchange.com/questions/224145/iframed-vf-page-fails-in-lightning-component-in-community-page), I've found a solution that works for my case.

In summary:

  1. Ensure that the visualforce page was accessible to the user's profile
  2. Add the visualforce page to the Community's page (Setup --> Communities --> MyCommunity --> Workspace --> Administration --> Pages --> force.com site --> Site Visualforce Pages)
  3. Change the iframe URL to /MyCommunity/apex/PageName

All Answers

SwethaSwetha (Salesforce Developers) 
HI Francesco,
Communities have their own Clickjack protection settings that may need to be adjusted to allow the use of iFrames in the Visualforce pages.

To check the Clickjack settings in the community follow these steps:
  • Gear icon | Setup | Feature Settings | Communities | All Communities
  • Click on the Workspaces (Next to community name)
  • Click on the Administration Panel | Click on Pages
  • Under Advanced Customizations, click Go to Force.com.
  • In the Site detail, on the right-hand side, you can see the clickjack protection level for the community.
  • Click the Edit button and adjust the Clickjack protection level.
For community sites, if you set clickjack protection to the level for the most protection, certain pages appear as blank pages. To avoid this problem, use the recommended setting.

Please see the article for more information: https://help.salesforce.com/articleView?id=000319416&type=1&mode=1

​​​​​​​Hope this helps you. Please mark this answer as best so that others facing the same issue will find this information useful. Thank you
Francesco DessìFrancesco Dessì
HI Swetha,

thanks for the answer. I took your advice, but the problem persists.
Francesco DessìFrancesco Dessì

On salesforce.stackexchange (https://salesforce.stackexchange.com/questions/224145/iframed-vf-page-fails-in-lightning-component-in-community-page), I've found a solution that works for my case.

In summary:

  1. Ensure that the visualforce page was accessible to the user's profile
  2. Add the visualforce page to the Community's page (Setup --> Communities --> MyCommunity --> Workspace --> Administration --> Pages --> force.com site --> Site Visualforce Pages)
  3. Change the iframe URL to /MyCommunity/apex/PageName
This was selected as the best answer