fix(youtubeplayer): use youtube-nocookie.com origin to fix error 152 on iOS#221
Open
EdJones wants to merge 1 commit intotriniwiz:mainfrom
Open
fix(youtubeplayer): use youtube-nocookie.com origin to fix error 152 on iOS#221EdJones wants to merge 1 commit intotriniwiz:mainfrom
EdJones wants to merge 1 commit intotriniwiz:mainfrom
Conversation
…on iOS YouTube tightened embed verification in 2025, causing error 152-4 for all WKWebView-based YouTube iframe embeds that set origin to 'https://www.youtube.com'. The WKWebView does not send proper HTTP Referer headers for loadHTMLString content, so YouTube rejects the mismatched origin. Change origin to 'https://www.youtube-nocookie.com/embed/' which is the confirmed fix adopted by Flutter (youtube_player_flutter#1087), React Native (react-native-webview#3889), and iOS WKWebView (YoutubePlayer-in-WKWebView#43) communities.
Author
|
This was generated by Claude cli 2.1.38. I checked some of the Youtube documentation, but I'm not expert enough to have evaluated the implications of this fix. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
originfromhttps://www.youtube.comtohttps://www.youtube-nocookie.com/embed/in the iOS implementation (index.ios.ts)Problem
YouTube tightened their embed verification in 2025. All WKWebView-based YouTube iframe embeds that set
origin: 'https://www.youtube.com'now receive error 152-4 ("This video is unavailable").The root cause is that
WKWebView.loadHTMLString:baseURL:does not send proper HTTPRefererheaders for cross-origin requests (WebKit Bug 169846), so YouTube's iframe API rejects the mismatched origin.This affects all videos — not specific ones.
Fix
Use
https://www.youtube-nocookie.com/embed/as the origin, which is the confirmed workaround adopted across multiple communities:Test plan