# Discourse embed fail (referer mixed up)

**URL:** https://meta.discourse.org/t/discourse-embed-fail-referer-mixed-up/201644
**Category:** Support
**Created:** [August 25, 2021, 8:18am UTC](https://meta.discourse.org/t/discourse-embed-fail-referer-mixed-up/201644 "2021-08-25T08:18:05Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![Bertrand\_Gorge](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/bertrand_gorge/32/228856_2.png) [@Bertrand\_Gorge](https://meta.discourse.org/u/Bertrand_Gorge)
#### Post date: [August 25, 2021, 8:18am UTC](https://meta.discourse.org/t/discourse-embed-fail-referer-mixed-up/201644/1 "2021-08-25T08:18:05Z")

</div>

Hello,

I’m in the process of embedding Discourse in a Mediawiki instance, and I seem to have a strange issue with it.

When I link my wiki page to an existing discourse topic, everything works like a charm:

```plaintext
window.DiscourseEmbed = { discourseUrl: 'https://forum.dev.tripleperformance.fr/',|
                          topicId: 18};

```

But when I try to create the topic it fails:

```plaintext
window.DiscourseEmbed = { discourseUrl: 'https://forum.dev.tripleperformance.fr/',|
                          discourseEmbedUrl = 'https:' + mw.config.get('wgServer') + '/wiki/' + mw.config.get('wgPageName')};

```

The iframe is loaded a first time with:

```plaintext
<meta id="data-embedded" data-referer="https://wiki.dev.tripleperformance.fr/wiki/Sandbox">

```

Then, after 30 seconds (caused by the `meta http-equiv="refresh"` in the iframe), the iframe reloads with:

```plaintext
<meta id="data-embedded" data-referer="https://forum.dev.tripleperformance.fr/embed/comments?embed_url=https%3A%2F%2Fwiki.dev.tripleperformance.fr%2Fwiki%2FSandbox">`

```

At this point, there’s an error in the console:

```plaintext
Failed to execute 'postMessage' on 'DOMWindow': The target origin provided ('https://forum.dev.tripleperformance.fr') does not match the recipient window's origin ('https://wiki.dev.tripleperformance.fr').

```

That’s probably because the referer in the data-embedded attribute is now self and not the parent page (which might actually be expected since the initiator of the refresh is self).

Note: I’m on a development machine which is slow due to docker and everything. It’s quite possible that I’m in a race condition or something…?

---

<div class="post-metadata">

### Author: ![Bertrand\_Gorge](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/bertrand_gorge/32/228856_2.png) [@Bertrand\_Gorge](https://meta.discourse.org/u/Bertrand_Gorge)
#### Post date: [August 25, 2021, 11:16am UTC](https://meta.discourse.org/t/discourse-embed-fail-referer-mixed-up/201644/2 "2021-08-25T11:16:41Z")

</div>

For what it’s worth, I’ve tried to create a post in the forum with a link to a wiki page, and it managed to resolve it (the embed is properly displayed). I also tried to curl the URL from within the container with success. I don’t understand why the new topic is not created right away…

---

<div class="post-metadata">

### Author: ![leonardo](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/leonardo/32/228634_2.png) [@leonardo](https://meta.discourse.org/u/leonardo)
#### Post date: [November 5, 2021, 7:00pm UTC](https://meta.discourse.org/t/discourse-embed-fail-referer-mixed-up/201644/3 "2021-11-05T19:00:39Z")

</div>

hello Bertrand!  
Hopefully this issue is solved for you by now, but if not, you might want to try the code in the [`test-passed`](https://github.com/discourse/discourse/tree/tests-passed) branch, which contains a fix from today for a problem with similar symptoms.

Said problem was introduced in the code AFTER August 25th when you reported this, so it’s unlikely this is the exact same issue.  
Still, if this is unresolved for you, you might want to give it a try.

Cheers!

---

<div class="post-metadata">

### Author: ![Bertrand\_Gorge](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/bertrand_gorge/32/228856_2.png) [@Bertrand\_Gorge](https://meta.discourse.org/u/Bertrand_Gorge)
#### Post date: [December 8, 2021, 2:43pm UTC](https://meta.discourse.org/t/discourse-embed-fail-referer-mixed-up/201644/4 "2021-12-08T14:43:55Z")

</div>

Hello Leonardo,

Thanks for this. I just tried - with not much more success. I did not dig too much into it though, as this type of integration won’t fit our platform (I prefer the topic to be created on demand through a bit of code and not for each page that we have in the platform).

---

<div class="post-metadata">

### Author: ![leonardo](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/leonardo/32/228634_2.png) [@leonardo](https://meta.discourse.org/u/leonardo)
#### Post date: [December 8, 2021, 2:47pm UTC](https://meta.discourse.org/t/discourse-embed-fail-referer-mixed-up/201644/5 "2021-12-08T14:47:27Z")

</div>

sorry to hear that, but it was worth a try 🙂  
Cheers!
