How can I troubleshoot Discourse comments embedding feature?



I’ve been trying for a while to embed Discourse comments on another site but still haven’t been able to make it work. I started following the instructions on this blog: Embedding Discourse in Static Sites - Evil Trout’s Blog and later on I found other issues, which I was able to fix with guidance from topics on this forum.

I’m now at the stage where I think everything is set up correctly, but for some reason topics don’t get created on the Discourse side (when visiting a page on the client site, the embedded iframe only shows “Loading discussion”). I’ve double-checked (dozens of times actually) the embed settings on Discourse, the embed snippet on the client site (including the canonical URLs), logs, etc and couldn’t find anything wrong, so I started looking into something on our deployment setup.

I just wanted to clarify how the embedding works so I can investigate a bit further. My understanding is that whenever a user visits a page on the blog or site that embeds the comments, a request is made to Discourse, which will pull the referring page contents and create a topic on the fly if it does not exist (my site does not have an RSS feed).

My questions are:

  • Is my assumption on how the embedding works correct?
  • How could I debug if indeed Discourse is having trouble creating the topics from the remote site?

Apologies if this is somewhat obvious but I’m not familiar with Discourse or Rails

Many thanks in advance

Can't embed comments: "Cannot read propery 'forEach' of undefined"

Can you provide a screenshot to your Discourse embedding settings? What is powering the backend of your blog/site? Is it static html (from a generator) or WordPress or Ghost?


@purldator here are my embed settings (sorry, I can’t embed images or link to them):

  • embeddable hosts:
  • feed polling enabled: {unchecked}
  • feed polling url: {blank}
  • embed by username: ddhdatasets
  • embed username key from feed: {blank}
  • embed category: Data Discovery Hub Datasets
  • embed post limit: 100
  • embed truncate: {unchecked}
  • embed whitelist selector: {blank}
  • embed blacklist selector: {blank}

My site is a data catalog based on CKAN , pages are generated from templates. Here’s what the Discourse snippet looks like on this page:

  <div id="discourse-comments"></div>

<script type="text/javascript">
  var discourseUrl = '',
      discourseEmbedUrl = '';

  (function() {
    var d = document.createElement('script'); d.type = 'text/javascript'; d.async = true;
      d.src = discourseUrl + 'javascripts/embed.js';
    (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(d);

Any pointers will be greatly appreciated.

discourseEmbed, does not match recipient window origin

Any pointers or ideas here would be greatly appreciated.

The rails log shows that the request is received correctly:

Started GET "/embed/comments?" for a
t 2015-06-24 15:14:27 +0000
Processing by EmbedController#comments as HTML
  Parameters: {"embed_url"=>""}
  Rendered embed/loading.html.erb within layouts/embed (0.9ms)
Completed 200 OK in 22ms (Views: 3.1ms | ActiveRecord: 5.9ms)

But nothing happens from there, no topics are created and on the client site the iframe keeps refreshing to the same Loading Discussion page. On the server, the topic_embeds table is empty.

I’ve tracked all the code up until topic_embed.rb where the remote contents should get pulled, but looking at the traffic on the server it doesn’t seem that the contents are being requested, so something is failing before.

Any ideas on what could that be?

I’m using v1.4.0.beta3 +55

Many thanks,

(Joel Natividad) #6

It seems that the following change broke embedding:

Embedding was working before on and before this change.

@eviltrout, I noticed that is on Discourse 1.4.0.beta1 which predates this change. Will it still work if its upgraded to the latest beta?

FYI, is running on v1.4.0.beta3 +71.


P.S. @amercader, fancy seeing you here :wink:

(Jeff Atwood) #7

I don’t think so… is on 1.4 beta 3 and as you can see the comments are embedded fine there on when you drill through to a blog entry.

(Joel Natividad) #8

If its not too much of a bother, can you create a new test blog post on

I noticed that old embedded posts were showing up properly, but when you try to create a new embed, it fails.

(nigelb) #9

Do you see these error log entries too? Open the page with the comments on Chrome with the JS console open and I see them come up after some time.


Yes, I do see them. It only happens in Chrome, Firefox seems to work fine.

Not sure if it is related to the topics not being created on the Discourse site though.

Embedding comments issue

I can confirm that rebuilding the Discourse site from scratch targeting v1.4.0.beta1 fixes the embedding. So it seems like some sort of regression has happened on the meantime (probably what @jqnatividad mentions).

(Joel Natividad) #12

Yep @nigelb, @amercader, I can confirm that we’re getting the same errors ourselves.

It’s good to know that embedding works again when using 1.4.0beta1.

(Ziirish) #13

Hi, I can confirm too:

  • v1.4.0.beta1 is working fine
  • v1.4.0.beta3 does not create the topics automatically

Unfortunately, I cannot seem to be able to reproduce the JS errors.

(marioMAN) #14

Hi there.
How do I roll back the update? I have searching but not much luck.


(Ziirish) #15

You can’t do the downgrade easily because database changes occurred between beta1 and beta3.
You’ll have to restore a database backup prior to the upgrade if you can.

Anyway, to install a fixed version of discourse, you can add the following lines in your container.yml file:

  version: v1.4.0.beta1

(Robin Ward) #16

I’m looking at this today. Hopefully I’ll have a solution soon.

(Robin Ward) #17

Okay sorry guys! There was indeed a bug here. It was serious enough that I’ve updated the latest beta to include it too. So if you are tracking beta just upgrade and you’ll get the patch.

(Jeff Atwood) #18

Where is our

(Jeff Atwood) #19