Skip to content

fix(youtubeplayer): use youtube-nocookie.com origin to fix error 152 on iOS#221

Open
EdJones wants to merge 1 commit intotriniwiz:mainfrom
EdJones:fix/youtube-error-152-ios-origin
Open

fix(youtubeplayer): use youtube-nocookie.com origin to fix error 152 on iOS#221
EdJones wants to merge 1 commit intotriniwiz:mainfrom
EdJones:fix/youtube-error-152-ios-origin

Conversation

@EdJones
Copy link

@EdJones EdJones commented Feb 14, 2026

Summary

  • Change the YouTube iframe player origin from https://www.youtube.com to https://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 HTTP Referer headers 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

  • Tested on iOS device (iPhone) with NativeScript Vue 3 app
  • Videos that previously showed error 152-4 now load and play correctly

…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.
@EdJones
Copy link
Author

EdJones commented Feb 14, 2026

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant