angular js load external site in iframe

2019-09-11 00:09发布

问题:

I have one angular js application which is running on nodejs. I want to load an external site, the external site is also my application which is running on different IP, with-in a div while loading the template url. So in template url I mentioned one HTML file. Inside that HTML file I had written like this.

<iframe src="myexternalurl"></iframe>

But in error console it is coming like:

Refused to display 'myexternalurl' in a frame because it set 'X-Frame-Options' to 'SAMEORIGIN'.

回答1:

Change the x-frame-options header to ALLOW-FROM {your app domain}

Apparently on your other application's host/server/app the header x-frame-options set to SAMEORIGIN you need to disable that header or correct it according to the x-frame-options possible values: https://developer.mozilla.org/en-US/docs/Web/HTTP/X-Frame-Options



回答2:

You can simply add following line to .htaccess in your external site (If its your application)

Header always unset X-Frame-Options

If you want to allow some specific site. refer the below link

https://developer.mozilla.org/en-US/docs/Web/HTTP/X-Frame-Options