# Error Embedding for existing posts

**URL:** https://meta.discourse.org/t/error-embedding-for-existing-posts/123086
**Category:** Support
**Created:** [July 16, 2019, 3:01pm UTC](https://meta.discourse.org/t/error-embedding-for-existing-posts/123086 "2019-07-16T15:01:31Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![elis](https://avatars.discourse-cdn.com/v4/letter/e/e19b73/32.png) [@elis](https://meta.discourse.org/u/elis)
#### Post date: [July 16, 2019, 3:01pm UTC](https://meta.discourse.org/t/error-embedding-for-existing-posts/123086/1 "2019-07-16T15:01:31Z")

</div>

Hello! We are getting an Error Embedding, the iframe says

```
Error Embedding
Referer: 
The referer was either not sent, or did not match any of the following hosts:

```

even though the domains are identical, and the console says:

```
Uncaught SyntaxError: Failed to execute 'postMessage' on 'Window': Invalid target origin '' in a call to 'postMessage'.
    _embed-application-3723be59920e64ecda9d66b1e7c4c55378fb9dadfa7f422febd4f1b346c1aa05.js:6 Uncaught DOMException: Failed to execute 'postMessage' on 'Window': Invalid target origin '' in a call to 'postMessage'.
        at e (https://sjc1.discourse-cdn.com/business5/brotli_asset/embed-application-3723be59920e64ecda9d66b1e7c4c55378fb9dadfa7f422febd4f1b346c1aa05.js:1:42)
        at window.onload (https://sjc1.discourse-cdn.com/business5/brotli_asset/embed-application-3723be59920e64ecda9d66b1e7c4c55378fb9dadfa7f422febd4f1b346c1aa05.js:1:470)

```

We are using the ‘Alternate configuration’ so the [solved topic](https://meta.discourse.org/t/solved-error-embedding/57276) doesn’t really help us.

> (Alternate Configuration) Linking to existing topics
> 
> Some people prefer to not have Discourse create topics for them automatically on their forums. They’d like to create the topics themselves, then simply tell their embedding code what topic they want to associate with. You can do this by slightly changing your embedding code:
> 
> ```plaintext
> <div id='discourse-comments'></div>
> 
> <script type="text/javascript">
> DiscourseEmbed = { discourseUrl: 'http://discourse.example.com/',
> topicId: 12345 };
> 
> (function() {
> var d = document.createElement('script'); d.type = 'text/javascript'; d.async = true;
> d.src = DiscourseEmbed.discourseUrl + 'javascripts/embed.js';
> (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(d);
> })();
> </script>
> 
> ```
> 
> The only difference here is we’ve replaced `discourseEmbedUrl` with the id of a topic from Discourse. If you do this, no topic will be created and the comments from that topic will automatically be displayed.

from [Embed Discourse comments on another website via Javascript](https://meta.discourse.org/t/embedding-discourse-comments-via-javascript/31963)

**Any way we can debug this easily, where does it get the referrer and why could it be empty?**  
**Is it a known/common issue and is there a way to _hide_ the iframe or its contents when it errors?**

Clicking through to the script where it errors it seems to not be able to find a referrer for a `postMessage` in the `#data-embedded` element.

---

<div class="post-metadata">

### Author: ![eviltrout](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/eviltrout/32/5275_2.png) [@eviltrout](https://meta.discourse.org/u/eviltrout)
#### Post date: [July 16, 2019, 3:55pm UTC](https://meta.discourse.org/t/error-embedding-for-existing-posts/123086/2 "2019-07-16T15:55:59Z")

</div>

You can look at the iframe that’s embedded in your page using the inspector and see if it has a meta tag with the correct referer. It should look something like: `<meta id='data-embedded' data-referere="YOUR_SITE">`

YOUR\_SITE should be automatically populated by the iframe.

---

<div class="post-metadata">

### Author: ![elis](https://avatars.discourse-cdn.com/v4/letter/e/e19b73/32.png) [@elis](https://meta.discourse.org/u/elis)
#### Post date: [July 16, 2019, 4:16pm UTC](https://meta.discourse.org/t/error-embedding-for-existing-posts/123086/3 "2019-07-16T16:16:47Z")

</div>

> [@eviltrout](#):
>
> It should look something like: `<meta id='data-embedded' data-referere="YOUR_SITE">`

`<meta id="data-embedded" data-referer="">`

It’s empty 😱What does this mean?

---

<div class="post-metadata">

### Author: ![eviltrout](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/eviltrout/32/5275_2.png) [@eviltrout](https://meta.discourse.org/u/eviltrout)
#### Post date: [July 16, 2019, 4:19pm UTC](https://meta.discourse.org/t/error-embedding-for-existing-posts/123086/4 "2019-07-16T16:19:33Z")

</div>

It means for some reason the iframe you are embedding is not being supplied with a referrer. I’m not sure if something is stripping it, like a proxy or redirect, or if it’s a browser issue.

---

<div class="post-metadata">

### Author: ![Falco](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/falco/32/179432_2.png) [@Falco](https://meta.discourse.org/u/Falco)
#### Post date: [October 2, 2020, 3:44pm UTC](https://meta.discourse.org/t/error-embedding-for-existing-posts/123086/6 "2020-10-02T15:44:29Z")

</div>

[https://meta.discourse.org/t/embedding-discourse-comments-via-javascript/31963/353?u=falco](https://meta.discourse.org/t/embedding-discourse-comments-via-javascript/31963/353)

---

<div class="post-metadata">

### Author: ![Falco](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/falco/32/179432_2.png) [@Falco](https://meta.discourse.org/u/Falco)
#### Post date: [October 2, 2020, 3:44pm UTC](https://meta.discourse.org/t/error-embedding-for-existing-posts/123086/7 "2020-10-02T15:44:34Z")

</div>


