Refused to display site in an iframe, X-Frame-Options to 'SAMEORIGIN' (ok)

https://stackoverflow.com/questions/24421260/refused-to-display-site-in-an-iframe-x-frame-options-to-sameorigin

Đã ok.

https://github.com/niutech/x-frame-bypassarrow-up-right

file-archive
3KB
file-archive
2KB
archive

Ask Questionarrow-up-rightAsked 6 years agoActive 5 months agoarrow-up-rightViewed 31k times52

Getting an error when i try to inspect element in chrome:

Refused to display 'http://www.samplesite.com/arrow-up-right' in a frame because it is set 'X-Frame-Options' to 'SAMEORIGIN'.

How to display a site inside an iframe in which the website has 'X-Frame-Options' to 'SAMEORIGIN'?

I tried searching on google but I could not find any proper solution, some are for asp.net only.iframearrow-up-right x-frame-optionsarrow-up-rightsharearrow-up-right improve this questionarrow-up-right follow edited Jan 21 at 12:45arrow-up-rightarrow-up-rightlbonnarrow-up-right2,1411919 silver badges3131 bronze badgesasked Jun 26 '14 at 1:53arrow-up-rightzenarrow-up-right26322 gold badges77 silver badges1919 bronze badges

add a commentarrow-up-right

4 Answers

Activearrow-up-rightOldestarrow-up-rightVotesarrow-up-right3

Web server conf,

for me i use nginx.conf

find add_header X-Frame-Options SAMEORIGIN; and change it toadd_header X-Frame-Options "ALLOWALL";

Your web server sends the header and blocks the content. You should probably change this setting to Allow from same origin.sharearrow-up-right improve this answerarrow-up-right follow answered Jul 30 '14 at 6:07arrow-up-rightyskarrow-up-right78788 silver badges88 bronze badges

add a commentarrow-up-right1

To solve this error:

Issue as mentioned in screenshot.

You just place this code in your .htaccess file according to the access level you want to provide:

  1. X-Frame-Options: deny

  2. X-Frame-Options: sameorigin

  3. X-Frame-Options: "allow-from https://example.com/"

sharearrow-up-right improve this answerarrow-up-right follow edited Jan 14 '19 at 14:27arrow-up-rightarrow-up-rightPaul Roubarrow-up-right34.2k88 gold badges6565 silver badges8080 bronze badgesanswered Jan 14 '19 at 14:13arrow-up-rightMustaneer Abdullaharrow-up-right7144 bronze badgesadd a commentarrow-up-right0

Me too I had a similar problem. Loading my web page into an iframe on another website I was getting this error: Refused to display 'https://mywebsite.comarrow-up-right' in a frame because it set 'X-Frame-Options' to 'sameorigin'.

I've solved using this web component that allow an IFrame to bypass the X-Frame-Options: deny/sameorigin response header. https://github.com/niutech/x-frame-bypassarrow-up-right

To test it, just save this code in an index.html file and place in the same directory the file x-frame-bypass.js that you can download from the above Github repository.

Since Safari doesn't support Customized built-in elements, I've added an extra script that allow the support. https://www.chromestatus.com/feature/4670146924773376arrow-up-right

sharearrow-up-right improve this answerarrow-up-right follow edited Jan 24 '19 at 6:26arrow-up-rightanswered Jan 22 '19 at 14:44arrow-up-rightDavide Casiraghiarrow-up-right1,22199 silver badges3030 bronze badges

  • 3Danger: This script works by passing everything through a proxy server. All data will be visible to the controller of the proxy server (including any login credentials submitted through the iframe). It depends on the proxy server being live (and open proxies like this tend to just strain under ever increasing load until they die and break your site which depends on them). Using a proxy to bypass X-Frame-Options dips into risky intellectual property territory too: you risk getting sued for copyright infringement. – Quentinarrow-up-right Jan 22 '19 at 14:47arrow-up-right

Last updated