If you’re encountering Error 153 when trying to load a YouTube iframe or embedded player, it’s because YouTube now requires a valid Referer header to identify the embedding client.
According to YouTube’s updated policy, you must include a Referer parameter when making requests to the embedded player.
See the official documentation here:
🔗 YouTube Embedded Player API Client Identity
To fix this, you can explicitly set the Referer header in your request, like so:
..loadRequest(
Uri.parse("https://www.youtube.com/embed/videoID"),
headers: {
// 🔑 These two lines allow YouTube's referer verification to pass
"Referer": "strict-origin-when-cross-origin",
// "Origin": "https://www.youtube-nocookie.com",
},
)