[Fixed]-Django refused to display YouTube video in a iframe because it set 'X-Frame-Options' to 'SAMEORIGIN'

1👍

Its your YouTube url your using, it needs to be the embed version. I just fixed similar issue on my site and worked.

Since your embedding it into an iframe it only makes since to use the YouTube embed url.

so example don’t use the short url for embedding in iframes, use the embed url.

WRONG: <iframe width="1260" height="709" src="<iframe width="1260" height="709" src="https://www.youtube.com/watch?v=xWRNBOXoLf8" frameborder="0" allow="autoplay; encrypted-media" allowfullscreen></iframe>" frameborder="0" allow="autoplay; encrypted-media" allowfullscreen></iframe>

RIGHT: <iframe width="1260" height="709" src="<iframe width="1260" height="709" src="https://www.youtube.com/embed/xWRNBOXoLf8?ecver=1" frameborder="0" allow="autoplay; encrypted-media" allowfullscreen></iframe>" frameborder="0" allow="autoplay; encrypted-media" allowfullscreen></iframe>

Use https://www.youtube.com/embed/xWRNBOXoLf8?ecver=1

👤Jtuck

Leave a comment