JavaScript embed won’t display embed, console log shows: Failed to execute postMessage on DOMWindow…

@willywongi You might be confused about what my issue was, so let me explain what happened.

  1. I’ve followed the steps but couldn’t get the comments to be embedded on the site.
  2. Turns out my Discourse app (installed on a different domain) is not able to “verify” that my blog posts exist because my main site did not implement the HEAD method on those URLs.
  3. After implementing handler for HEAD requests for those paths, the embed works.

To see if you have the same issue as I do, run curl against the URL that contain the blog post / wherever you want your comment embed to appear.

For example, if your URL is https://example.com/blog/awesome-post, go to terminal and run

curl https://example.com/blog/awesome-post -I

This will run a HEAD request to that URL and give you the result. If the status code is anything other than 200 (that’s the number on the first line of the response), e.g.:

HTTP/2 200

then the server doesn’t implement the HEAD method (OR it has issue responding to it).

If the response IS 200 then the embed issue has nothing to do with HEAD requests.