Error 'X-Frame-Options' to 'SAMEORIGIN' ionic2

1

I'm inserting an iframe in ionic2 imported from a url of a page I've tried some if I leave and youtube also but like the google or preincipal I have to place link do not let me leave this error:

 Refused to display 'http://soporte.estadisticassena.com/edis/www/engenn11le04ob08/' in a frame because it set 'X-Frame-Options' to 'SAMEORIGIN'.

this is the component:

import { Component } from '@angular/core';
import {SafeResourceUrl, DomSanitizer} from '@angular/platform-browser';
import { AlertController, LoadingController, NavController } from 'ionic-angular';

@Component({
  selector: 'sena',
  templateUrl: 'sena.html'
})

export class Sena{

   url: SafeResourceUrl;

  constructor(
    public navCtrl: NavController,
    private alertCtrl: AlertController,
    public loadingCtrl: LoadingController,
    public sanitizer: DomSanitizer
  ){
    this.url = sanitizer.bypassSecurityTrustResourceUrl('https://www.google.com.co/');
  }
}

This is the html:

 <iframe class="iframe-sena" height="190" onload="this.width=screen.width" [src]="url" frameborder="0" ></iframe>

Thank you very much.

    
asked by Albert Arias 19.03.2017 в 23:25
source

1 answer

2

Inside the response of the page loaded is the HTTP header:

x-frame-options: SAMEORIGIN

This deactivates the display of this page in an IFRAME. See: link

Unfortunately, Google and other sites have disabled support for uploading their content to an iframe from an external site. Check link and link

The way to show this content in an iframe is no longer possible in a normal way (using src in the iframe). The closest solution is to use a "proxy" page on your own server that serves the content of that page but from a local source.

Ex: Load a local page

<iframe src="mysite/proxypage?url=http://www.google.com/search?q=test"></iframe>

And the page's controller downloads the content of the url and delivers it as an answer.

    
answered by 20.03.2017 / 15:36
source