1

How to hide console error: Failed to execute 'postMessage' on 'DOMWindow': The target origin provided ('Url1') does not match the recipient window's origin ('Url2')?

My goal here is just to hide the console error and not to fix the actual issue of posting messages to the 'wrong' urls.

JustANoob
  • 93
  • 2
  • 10
  • https://stackoverflow.com/questions/44622318/how-to-unhide-filtered-messages-in-chrome-developer-tools-on-a-mac https://stackoverflow.com/questions/4500741/suppress-chrome-failed-to-load-resource-messages-in-console – Bergi Dec 15 '20 at 22:47
  • 1
    Interesting! I took a look but it seems those are browser configs to hide the logs for myself. My goal is to hide those for all clients using my website. I have a list of trusted domains but due to complicated architecture, it is impossible to know which one is 'the right one' so I post to all of them (but I don't want clients to see the error log). – JustANoob Dec 17 '20 at 17:59
  • Is this a log message the browser console shows by itself, or is it actually an exception thrown in your code? You'd need to wrap the `postMessage` in a try `try` block and `catch` the error. – Bergi Dec 17 '20 at 18:58
  • I tried that but it doesn't work because the receiver is the one logging the error. Is there a way to make postMessage silently ignore the message without the error in the console? – JustANoob Dec 18 '20 at 22:32
  • Not to my knowledge. You should however be able to test the origin yourself before calling `postMessage`. – Bergi Dec 18 '20 at 22:43

0 Answers0