# Failed to execute postMessage on DOMWindow: The target origin provided does not match

**URL:** https://meta.discourse.org/t/failed-to-execute-postmessage-on-domwindow-the-target-origin-provided-does-not-match/77260
**Category:** Self-hosting
**Created:** [1월 4, 2018, 5:47오후 UTC](https://meta.discourse.org/t/failed-to-execute-postmessage-on-domwindow-the-target-origin-provided-does-not-match/77260 "2018-01-04T17:47:53Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![Ingo\_Karstein](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/ingo_karstein/32/206923_2.png) [@Ingo\_Karstein](https://meta.discourse.org/u/Ingo_Karstein)
#### Post date: [1월 4, 2018, 5:47오후 UTC](https://meta.discourse.org/t/failed-to-execute-postmessage-on-domwindow-the-target-origin-provided-does-not-match/77260/1 "2018-01-04T17:47:53Z")

</div>

Hi all,

I try to solve this error since two days but with no success.

I use Discourse 2.0 (today) and used 1.9.x (yesterday).

I have a Ubuntu server with docker on it.

On the host I run nginx as reverse proxy with SSL offloading.

On the machine I host several docker images that run fine.

I installed Discource using “standalone.yml” with some modifications, e.g. port mapping from 80xx (host) to 80 (Discourse).

The Discourse URL from the Internet is something like this: [https://discourse.example.com](https://discourse.example.com).

I try to embedd Discourse in a web site on a complete other domain, e.g. [https://doc.test.dom](https://doc.test.dom)

I added embedding settings to Discourse.

In the JavaScript console I get always this error:

Failed to execute ‘postMessage’ on ‘DOMWindow’: The target origin provided (‘https ://discourse.example.com’) does not match the recipient window’s origin (‘https ://doc.test.com’)

Any ideas?

I already tried to modify CORS settings in the Docker-Host-nginx.conf. No success.

Regards  
Ingo

---

<div class="post-metadata">

### Author: ![gerhard](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/gerhard/32/119479_2.png) [@gerhard](https://meta.discourse.org/u/gerhard)
#### Post date: [1월 5, 2018, 10:13오전 UTC](https://meta.discourse.org/t/failed-to-execute-postmessage-on-domwindow-the-target-origin-provided-does-not-match/77260/2 "2018-01-05T10:13:14Z")

</div>

Did you follow this Howto? [Embed Discourse comments on another website via Javascript](https://meta.discourse.org/t/embedding-discourse-comments-via-javascript/31963)

Make sure that you created an embeddable host in Discourse for `doc.test.com` and that the URLs in the JavaScript you embedded are correct and, in your case, use HTTPS.

It would be easier to help if we knew the actual URLs of your site. And did you change the error message you posted in any way? Because there is a whitespace in the URLs (`https ://discourse.example.com`).

---

<div class="post-metadata">

### Author: ![Ingo\_Karstein](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/ingo_karstein/32/206923_2.png) [@Ingo\_Karstein](https://meta.discourse.org/u/Ingo_Karstein)
#### Post date: [1월 5, 2018, 2:31오후 UTC](https://meta.discourse.org/t/failed-to-execute-postmessage-on-domwindow-the-target-origin-provided-does-not-match/77260/3 "2018-01-05T14:31:08Z")

</div>

I had to add the white spaces in the error message because the platform did reject my post as a new user is only allowed to have only 2 URLs in a new post. 😉

I added the url “[doc.test.com](http://doc.test.com)” in the embedding settings of Discourse.

---

<div class="post-metadata">

### Author: ![Ingo\_Karstein](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/ingo_karstein/32/206923_2.png) [@Ingo\_Karstein](https://meta.discourse.org/u/Ingo_Karstein)
#### Post date: [1월 5, 2018, 4:08오후 UTC](https://meta.discourse.org/t/failed-to-execute-postmessage-on-domwindow-the-target-origin-provided-does-not-match/77260/4 "2018-01-05T16:08:01Z")

</div>

Sorry… I forgot… Yes. I followed the tutorial.

---

<div class="post-metadata">

### Author: ![vinothkannans](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/vinothkannans/32/86465_2.png) [@vinothkannans](https://meta.discourse.org/u/vinothkannans)
#### Post date: [1월 5, 2018, 4:20오후 UTC](https://meta.discourse.org/t/failed-to-execute-postmessage-on-domwindow-the-target-origin-provided-does-not-match/77260/5 "2018-01-05T16:20:48Z")

</div>

You are using SSL and `force_https` is not yet enabled in your site settings. It can be the reason.

---

<div class="post-metadata">

### Author: ![Ingo\_Karstein](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/ingo_karstein/32/206923_2.png) [@Ingo\_Karstein](https://meta.discourse.org/u/Ingo_Karstein)
#### Post date: [1월 5, 2018, 8:07오후 UTC](https://meta.discourse.org/t/failed-to-execute-postmessage-on-domwindow-the-target-origin-provided-does-not-match/77260/6 "2018-01-05T20:07:08Z")

</div>

I changed the setting in Discourse administration. But I get the same result.

---

<div class="post-metadata">

### Author: ![Ingo\_Karstein](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/ingo_karstein/32/206923_2.png) [@Ingo\_Karstein](https://meta.discourse.org/u/Ingo_Karstein)
#### Post date: [1월 5, 2018, 8:27오후 UTC](https://meta.discourse.org/t/failed-to-execute-postmessage-on-domwindow-the-target-origin-provided-does-not-match/77260/7 "2018-01-05T20:27:19Z")

</div>

It works now! My last try was to edit the “discourseEmbedUrl” in JavaScript that need to be exact the referer URL / URL of the page where Discourse is embedded in.

Thank you all for your help!

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [1월 5, 2018, 11:51오후 UTC](https://meta.discourse.org/t/failed-to-execute-postmessage-on-domwindow-the-target-origin-provided-does-not-match/77260/8 "2018-01-05T23:51:24Z")

</div>


