Users reported that YouTube embeds stopped working on Discourse servers located in Europe due to YouTube’s new consent page redirect, which lacks oEmbed/OpenGraph tags needed for oneboxing. chrispanag identified the issue as stemming from YouTube’s compliance with European regulations, confirmed by server location differences (e.g., meta.discourse.org, outside Europe, worked fine). Iceman noted that short URLs (youtu.be) and non-www URLs temporarily bypassed the consent page, though this workaround was deemed unstable. jamie.wilson proposed and implemented a fix by fetching YouTube’s embed URLs and parsing their JSON response, which was merged into Discourse. Users including Richie and bartv confirmed the fix worked after updating. The community praised the Discourse team for addressing a non-Discourse issue, with Richie highlighting their exceptional support. Some users asked for backporting to stable releases, but Falco explained Discourse’s policy to only backport critical security fixes, noting that the stable channel is less tested and not recommended for dynamic web environments. pfaffman added that even “stable” may be less reliable than beta due to fewer users testing it. Alternative fixes like using youtube-nocookie.com were also suggested and confirmed to work Drakon74.
When you are trying to one-box a youtube URL, Youtube automatically redirects to a page named consent.youtube.com. This page doesn’t have an oEmbed/OpenGraph tag, so oneboxing is unfortunately failing.
This is definitely not Discourse’s flaw, but has to do with a (as it seems) breaking change on Youtube’s end. I suspect this happens due to some new Europe regulation, because I can’t reproduce on meta.
Our server is in Europe (Germany) and you can see the redirecting URL here.
I logged on here last night to report this exact issue as it’s been happening to us recently too, but when I pasted my example YouTube URL, it worked fine here on meta
The issue is related to the “Data Consent Form” and OneBox catches that instead of the actual content.
If instead of using the https://youtube.com/watch?v=XYZ you change it to https://youtu.be/XYZ it works because that’s the “Share URL” and that doesn’t pop the Consent Dialog. (However, this is not ideal).
Unless Discourse/OneBox “autochanges” the URL to the “Short Version” when oneboxing, maybe, as a quick fix? IDK, just giving more info/feedback.
As a media-heavy community we have thousands and thousands of YouTube videos shared by our members with several hundred being posted per month.
This change by YouTube is proving to be a real problem already but I don’t think it’s something that can be solved by Discourse if YouTube themselves are forcing a redirect to their consent page?
So if discourse were to rewrite the url as you describe when the post was cooked that would fix it?
If that’s the case a plugin could fix it (maybe even a theme component?) , and I would guess that it would be PR welcome and/or that they’ll fix it pretty quick.
Just find it very “funny” because both: https://youtu.be/VIDEO and deleting “www” on the normal url, so: https://youtube.com/watch?v=VIDEO work. So the criteria for “blocking” with the consent popup is not very “logical” from a user’s perspective.
Is it possible for you to test those URLs again? This is what I’m currently seeing from a server in Frankfurt (wget output edited to just show the redirects):