[solved] Error Embedding

Hi, similar to this post, I’m getting errors embedding comments in a static site: https://bigsmall.io/articles/action-brands-are-important-urgent-credible/

In the browser console, I it says “Loading Discussion”, then “Error Embedding” with this in the JavaScript console:

Failed to execute 'postMessage' on 'DOMWindow': The target origin provided ('https://community.bigsmall.io') does not match the recipient window's origin ('https://bigsmall.io').

The topics are created in Discourse - I see them in the “Let’s get this discussion started” page listing topics. From the dates, the topics may have been made from the RSS feed integration.

Any suggestions?

Bam! Fixed it. Make sure the discourseEmbedUrl is a full URL, not a relative path. E.g.:

              var url="https://dev.bigsmall.io/articles/action-brands-are-important-urgent-credible/"
              DiscourseEmbed = { discourseUrl: 'https://community.bigsmall.io/',
                                 discourseEmbedUrl: url };
              
              (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);
              })();
4 Likes

@eviltrout can we check for this somehow and warn if it is a partial URL?

2 Likes

Sure. It can only show in the Javascript console but it would have helped this person diagnose their issue:

https://github.com/discourse/discourse/commit/c40d8d37ddf75298ca837a60f42251e6f1fdf3d8

2 Likes

Yes! That would have saved us some time. This is a really cool feature BTW, it turns drive-by comments into a community which is cool.

I made a quick comment on the PR about protocol independent URLs. Cheers and thanks for an awesome project!

Mike

2 Likes