-
Notifications
You must be signed in to change notification settings - Fork 72
Description
Today we have a discussion about YouTube player in an extension page.
<iframe id="ytplayer" type="text/html" width="640" height="360"
src="https://www.youtube.com/embed/M7lc1UVf-VE?autoplay=1"
frameborder="0"></iframe>
Above is the code that users embed a youtube video in a web page or extension page. Recently, it doesn't work in extension pages, but still works in web pages. After investigation, I found YouTube asks all clients (including embed youtube player) to send HTTP Referer header. If there is no referer, youtube doesn't allow you to use it (show a 153 error code – The request does not include the HTTP Referer header or equivalent API Client identification).
The key difference between web page and extension page is the browser doesn't send HTTP Referer for an iframe in an extension page, it sends this header if the iframe is embedded in web pages.
I'm not quite sure why the browser does this by default in extension pages. We have two workarounds in the prior discussion link, but it requires more work for developers. Could browsers offer a better solution?