youtube-player icon indicating copy to clipboard operation
youtube-player copied to clipboard

'postMessage' on 'DOMWindow' error, how to get rid of it or at least supress it?

Open andrewdobra opened this issue 4 years ago • 2 comments

I'm working on a project where we have several videos loading on the same page and we've run into this error that also shows up in your example of multiple-videos.

The exact text is "Failed to execute 'postMessage' on 'DOMWindow': The target origin provided ('https://www.youtube.com') does not match the recipient window's origin ('http://127.0.0.1:8000')." but I guess you're already familiar with it.

We've tried multiple fixes from the web, we've even done our own implementation but to no avail, do you know how get rid of this error or at least suppress it such that it doesn't pollute the console? One thing to note is that in our implementation there were only half the number of errors so probably some requests or "postMessage" calls repeat more often in yours.

EDIT: One thing I forgot to mention, the videos do load after all, the problem is just that the errors show up in console.

andrewdobra avatar Feb 16 '21 10:02 andrewdobra

Just a first guess, that seems like the code for the YouTube API that is fetched from YouTube.com is not allowed to post messages to the window while in your page. I'm not sure but this may be something you can allow with a Content Security Policy (CSP). Just be cautious 🙂

CSP works something like this: Content-Security-Policy: default-src 'self' trusted.com *.trusted.com Here's more info: https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP

On another note, it's hard to understand why this needs to happen at the moment, so just be aware that something else could be going on.

Good luck!

resistdesign avatar Feb 17 '21 02:02 resistdesign

Having the same issue. @andrewdobra have you managed to solve this for yourself?

mabasic avatar Apr 26 '22 20:04 mabasic