javascripthttpsdisqus

Why are disqus comments not loading over https?


The disqus comments are loading here: http://www.oddprints.com/help but not here: https://www.oddprints.com/help any ideas?

All resources appear to be secure (protocol relative urls) so I don't think it's that.


Solution

  • It because disqus was treating the two urls as different and therefore loading different threads. If you want both http and https urls to have the same comments thread on it, you need to supply a canonical url in the disqus config. This is how I did it:

    <div id="disqus_thread"></div>
    <script>
        /**
         *  https://disqus.com/admin/universalcode/#configuration-variables
         */
        var disqus_config = function () {
            this.page.url = "http://www.oddprints.com/help";
            //this.page.identifier = "oddprints"; // add a different id here if you want a fresh thread....
        };
        (function() {
            var d = document, s = d.createElement('script');
            s.src = '//oddprints.disqus.com/embed.js';
            s.setAttribute('data-timestamp', +new Date());
            (d.head || d.body).appendChild(s);
        })();
    </script>
    <noscript>Please enable JavaScript to view the <a href="https://disqus.com/?ref_noscript" rel="nofollow">comments powered by Disqus.</a></noscript>
    

    Note that in the config I passed the http url as the canonical url and I've not set the page.identifier. I've done this so that it continues to serve up the comments I already had from back when it was just http and using an older version of the disqus snippet.