Refused to display 'https://www.youtube.com/watch?v=...' in a frame because it set 'X-Frame-Options' to 'sameorigin'

Hi
Actually I am stuck with my video not working’please can u look at this
in html

 <iframe width="100%" height="315" [src]="videoUrl" frameborder="0" allowfullscreen></iframe>

in ts

this.videoUrl = this.domSanitizer.bypassSecurityTrustResourceUrl(https://www.youtube.com/watch?v=yO7kQQ3YWzY);

error is

Refused to display 'https://www.youtube.com/watch?v=yO7kQQ3YWzY' in a frame because it set 'X-Frame-Options' to 'sameorigin'.
VM2889 main.js:36595 GET https://www.youtube.com/watch?v=yO7kQQ3YWzY net::ERR_BLOCKED_BY_RESPONSE
1 Like

Solution for this that I found is

this.video_link="https://www.youtube.com/embed/"+filename;

above filename is your last string in ‘https://www.youtube.com/watch?v=yO7kQQ3YWzY

filename is yO7kQQ3YWzY

so finally it will be

https://www.youtube.com/embed/yO7kQQ3YWzY"
1 Like

this works for me . Thanks

For the youtube it is ok but what if we implement www.youtube.com/search and the user type a name then should open in iframe youtube and get the input name to create search how do you solve this do you have any idea ?