# Some pages on my site won't fully embed comments

**URL:** https://meta.discourse.org/t/some-pages-on-my-site-wont-fully-embed-comments/69913
**Category:** Support
**Created:** [2017 年 9 月 12 日午後 6:18 UTC](https://meta.discourse.org/t/some-pages-on-my-site-wont-fully-embed-comments/69913 "2017-09-12T18:18:13Z")
**Posts on this page:** 12
**Page:** 1

<div class="post-metadata">

### Author: ![downey](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/downey/32/166878_2.png) [@downey](https://meta.discourse.org/u/downey)
#### Post date: [2017 年 9 月 12 日午後 6:18 UTC](https://meta.discourse.org/t/some-pages-on-my-site-wont-fully-embed-comments/69913/1 "2017-09-12T18:18:13Z")

</div>

I have set up an embedding using the JS snippet, linking a project documentation site (driven by Sphinx & Read The Docs) to our forum to allow people to comment there on each document.

Overall, the embedding is working – many pages on the site are working fine. But a **few (apparently) random pages don’t work at all.** The IFRAME appears, as does the site’s logo, but it hangs saying `"Loading Discussion..."`

> ![image](https://global.discourse-cdn.com/meta/original/3X/0/a/0a6f7ea46fad33142f5319ed01dd9bd90cabd8d1.png)

The associated topic for these pages with the error is not being created, too. It’s unclear why some pages would fully work and some wouldn’t. The pages that work, do work fine, create the topic excerpt correctly in Discourse, show existing comments from the associated topic, etc.

> ![image](https://global.discourse-cdn.com/meta/original/3X/8/8/88981f51ab95c1418473fb95664d85c734fe69ad.png)

> ![image](https://global.discourse-cdn.com/meta/original/3X/2/c/2c1cf52e1330243ddf0f74870b520bd990118e82.png)

Does anyone have ideas on how best to troubleshoot this? (I can provide example pages if someone is curious to dive deeper.) Thanks!

---

<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: [2017 年 9 月 12 日午後 11:18 UTC](https://meta.discourse.org/t/some-pages-on-my-site-wont-fully-embed-comments/69913/2 "2017-09-12T23:18:03Z")

</div>

Any errors in the browser’s F12 JS console?

---

<div class="post-metadata">

### Author: ![downey](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/downey/32/166878_2.png) [@downey](https://meta.discourse.org/u/downey)
#### Post date: [2017 年 9 月 12 日午後 11:26 UTC](https://meta.discourse.org/t/some-pages-on-my-site-wont-fully-embed-comments/69913/3 "2017-09-12T23:26:05Z")

</div>

> [@codinghorror](#):
>
> Any errors in the browser’s F12 JS console?

Yes, but only within the IFRAME itself, and **only** on the pages that don’t render the content fully. (In other words, this does not appear when the comments render successfully on the same site.)

```plaintext
Failed to execute 'postMessage' on 'DOMWindow': The target origin provided ('http://forum.example.org') does not match the recipient window's origin ('http://docs.example.org').

postUp @ comments?embed_url=http%3A%2F%2Fdocs.example.org%2Fen%2Flatest%2Fprivacy-policy.html:17
window.onload @ comments?embed_url=http%3A%2F%2Fdocs.example.org%2Fen%2Flatest%2Fprivacy-policy.html:38

```

---

<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: [2017 年 9 月 20 日午後 7:32 UTC](https://meta.discourse.org/t/some-pages-on-my-site-wont-fully-embed-comments/69913/4 "2017-09-20T19:32:32Z")

</div>

You have a mismatch in the allowed URLs there per the error message.

> Failed to execute ‘postMessage’ on ‘DOMWindow’: The target origin provided (‘[http://forum.example.org](http://forum.example.org)’) does not match the recipient window’s origin (‘[http://docs.example.org](http://docs.example.org)’).

---

<div class="post-metadata">

### Author: ![downey](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/downey/32/166878_2.png) [@downey](https://meta.discourse.org/u/downey)
#### Post date: [2017 年 9 月 20 日午後 7:34 UTC](https://meta.discourse.org/t/some-pages-on-my-site-wont-fully-embed-comments/69913/5 "2017-09-20T19:34:48Z")

</div>

That would make sense, but does not seem to explain why some .html pages **on the same site** work and some do not.

We can actually change **foo.html** (the real page filename) to **bar.html** in the value of `discourseEmbedUrl` and it works. 🤔

---

<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: [2017 年 9 月 20 日午後 7:35 UTC](https://meta.discourse.org/t/some-pages-on-my-site-wont-fully-embed-comments/69913/6 "2017-09-20T19:35:43Z")

</div>

Are those pages redirecting to some other URL?

Maybe make the request and watch the network tab in your browser’s f12 console.

---

<div class="post-metadata">

### Author: ![downey](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/downey/32/166878_2.png) [@downey](https://meta.discourse.org/u/downey)
#### Post date: [2017 年 9 月 20 日午後 8:37 UTC](https://meta.discourse.org/t/some-pages-on-my-site-wont-fully-embed-comments/69913/7 "2017-09-20T20:37:23Z")

</div>

> [@codinghorror](#):
>
> Are those pages redirecting to some other URL?

Nope, no HTTP redirection involved, unfortunately.

- Regardless of whether we set the value of `discourseEmbedUrl` to either the dymanic URL using `window.location.href`, or just hard code the actual URL, we get the same error as above.

- If we hard code the value of `discourseEmbedUrl` to an existing .html page on the same site that already has an associated topic, things load fine.

- If we hard code the value of `discourseEmbedUrl` to a **non-existing**.html page on the same site that does not have any associated topic already, we also get the same error.

We are hoping to get a look at our rails log to see if we can see what might be happening (or not) on the back end. Will update here when we learn more.

---

<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: [2017 年 9 月 26 日午後 7:01 UTC](https://meta.discourse.org/t/some-pages-on-my-site-wont-fully-embed-comments/69913/10 "2017-09-26T19:01:55Z")

</div>

Just so I am clear:

Are no new topics ever being created anymore, or are they still only being created for random URLs? Is there any rhyme or reason to the URLs that don’t work?

You’ll definitely want to take a look at the Rails logs. It’s possible sidekiq is having problems reaching the destination for some reason. It is necessary that your server can reach the page.

---

<div class="post-metadata">

### Author: ![downey](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/downey/32/166878_2.png) [@downey](https://meta.discourse.org/u/downey)
#### Post date: [2017 年 9 月 26 日午後 7:07 UTC](https://meta.discourse.org/t/some-pages-on-my-site-wont-fully-embed-comments/69913/11 "2017-09-26T19:07:38Z")

</div>

> [@eviltrout](#):
>
> Are no new topics ever being created anymore, or are they still only being created for random URLs?

New topics are being created – not just for random URL’s but most any URL except a few problematic ones.

> [@eviltrout](#):
>
> Is there any rhyme or reason to the URLs that don’t work?

Nothing that we’ve found yet. In fact, we can, **on the same page** , change the URL that we’re passing the embed.js script, and it works. So it doesn’t seem to be anything on the page itself that’s causing the problem.

> [@eviltrout](#):
>
> You’ll definitely want to take a look at the Rails logs.

Yeah, we think this is the logical next steps. Waiting to hear back from the hosting folks on coordinating this troubleshooting. 😉

> [@eviltrout](#):
>
> It’s possible sidekiq is having problems reaching the destination for some reason. It is necessary that your server can reach the page.

Page access seems unlikely since they’re simply different \*.html pages on the same site that we’re working with, but it’s possible, I suppose.

---

<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: [2017 年 9 月 27 日午後 12:58 UTC](https://meta.discourse.org/t/some-pages-on-my-site-wont-fully-embed-comments/69913/15 "2017-09-27T12:58:37Z")

</div>

> [@downey](#):
>
> Yeah, we think this is the logical next steps. Waiting to hear back from the hosting folks on coordinating this troubleshooting.

Apologies but I didn’t realize you meant on our hosting 🙂

We can actually check our error logs for this - can you tell us the last time you saw the problem happen? Otherwise it’s going to be tricky to discover. The exact URL of the embed would be useful too.

---

<div class="post-metadata">

### Author: ![downey](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/downey/32/166878_2.png) [@downey](https://meta.discourse.org/u/downey)
#### Post date: [2017 年 9 月 27 日午後 3:00 UTC](https://meta.discourse.org/t/some-pages-on-my-site-wont-fully-embed-comments/69913/16 "2017-09-27T15:00:00Z")

</div>

Hey there. So I was looking again at this site – hadn’t done so yet this week – and noticed that the pages in question started creating topics as of 2 days ago. Not sure how or why this happened, but suffice to say cannot repro this issue anymore!

Thanks to all for your brainpower nevertheless. 🙂

---

<div class="post-metadata">

### Author: ![jomaxro](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jomaxro/32/126216_2.png) [@jomaxro](https://meta.discourse.org/u/jomaxro)
#### Post date: [2017 年 9 月 27 日午後 3:01 UTC](https://meta.discourse.org/t/some-pages-on-my-site-wont-fully-embed-comments/69913/17 "2017-09-27T15:01:07Z")

</div>


