Skip to content

There is no HTTP Referer header for iframe in an extension page #896

@hanguokai

Description

@hanguokai

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    discussionNeeds further discussionneeds-triage: firefoxFirefox needs to assess this issue for the first timeneeds-triage: safariSafari needs to assess this issue for the first time

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions