Overcoming “Display forbidden by X-Frame-Options”

后端 未结 26 2181
梦谈多话
梦谈多话 2020-11-21 06:31

I\'m writing a tiny webpage whose purpose is to frame a few other pages, simply to consolidate them into a single browser window for ease of viewing. A few of the pages I\'

相关标签:
26条回答
  • 2020-11-21 07:07

    There is a plugin for Chrome, that drops that header entry (for personal use only):

    https://chrome.google.com/webstore/detail/ignore-x-frame-headers/gleekbfjekiniecknbkamfmkohkpodhe/reviews

    0 讨论(0)
  • 2020-11-21 07:07

    I was using Tomcat 8.0.30, none of the suggestions worked for me. As we are looking to update the X-Frame-Options and set it to ALLOW, here is how I configured to allow embed iframes:

    • Navigate to Tomcat conf directory, edit the web.xml file
    • Add the below filter:
    <filter>
                <filter-name>httpHeaderSecurity</filter-name>
                <filter-class>org.apache.catalina.filters.HttpHeaderSecurityFilter</filter-class>
                       <init-param>
                               <param-name>hstsEnabled</param-name>
                               <param-value>true</param-value>
                       </init-param>
                       <init-param>
                               <param-name>antiClickJackingEnabled</param-name>
                               <param-value>true</param-value>
                       </init-param>
                       <init-param>
                               <param-name>antiClickJackingOption</param-name>
                               <param-value>ALLOW-FROM</param-value>
                       </init-param>
                <async-supported>true</async-supported>
           </filter>
    
           <filter-mapping>
                       <filter-name>httpHeaderSecurity</filter-name>
                       <url-pattern>/*</url-pattern>
                       <dispatcher>REQUEST</dispatcher>
           </filter-mapping> 
    
    • Restart Tomcat service
    • Access the resources using an iFrame.
    0 讨论(0)
  • 2020-11-21 07:12

    Adding a

      target='_top'
    

    to my link in the facebook tab fixed the issue for me...

    0 讨论(0)
  • 2020-11-21 07:12

    I tried nearly all suggestions. However, the only thing that really solved the issue was:

    1. Create an .htaccess in the same folder where your PHP file lies.

    2. Add this line to the htaccess:

      Header always unset X-Frame-Options

    Embedding the PHP by an iframe from another domain should work afterwards.

    Additionally you could add in the beginning of your PHP file:

    header('X-Frame-Options: ALLOW');
    

    Which was, however, not necessary in my case.

    0 讨论(0)
  • 2020-11-21 07:13

    This is the solution guys!!

    FB.Event.subscribe('edge.create', function(response) {
        window.top.location.href = 'url';
    });
    

    The only thing that worked for facebook apps!

    0 讨论(0)
  • 2020-11-21 07:13

    I came across this issue when running a wordpress web site. I tried all sorts of things to fix it and wasn't sure how, ultimately the issue was because I was using DNS forwarding with masking, and the links to external sites were not being addressed properly. i.e. my site was hosted at http://123.456.789/index.html but was masked to run at http://somewebSite.com/index.html. When i entered http://123.456.789/index.html in the browser clicking on those same links resulted in no X-frame-origins issues in the JS console, but running http://somewebSite.com/index.html did. In order to properly mask you must add your host's DNS name servers to your domain service, i.e. godaddy.com should have name servers of example, ns1.digitalocean.com, ns2.digitalocean.com, ns3.digitalocean.com, if you were using digitalocean.com as your hosting service.

    0 讨论(0)
提交回复
热议问题