Links without sub-folder path in embedded comments (Continue Discussion and user links)

I’ve just found a bug with combination of embedded comments and sub-folder installation:
‘Continue Discussion’ button and user links does not respect subfolder path.
But ‘Start Discussion’ button does respect subfolder path.
So I can only post once on embedded thread.

Here is the example:
Discourse installed into:
‘Start Discussion’ url is
‘Continue Discussion’ url is just /t/bournemouth-west-ham-united-new-sports-rating/13

Discourse Version v1.5.0.beta8 +11 (Docker + subfolder official guide)

A quick and dirty work-around I can come up with is the following:
add this javascript to Discourse embedded code so the full Discourse code will be:

DiscourseEmbed = { discourseUrl: '',
                   discourseEmbedUrl: window.location.href };

(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);

    // Temporary work around
    setTimeout(function () {
        $('#discourse-embed-frame').contents().find("a").each(function () {
            var value = $(this).attr('href');
            if (!value.startsWith('http')) {
                $(this).attr('href', '' + value);
    }, 3000);

Hope this help later in debugging this problem.

I think this commit should fix you up:


Thank you very much!
I apply this patch in my installation, and during application figured out two more places with similar problems:
You forget to fix /users/ links at app/views/embed/comments.html.erb lines 19 and 23

1 Like

I created a Pull Request, it should completely fix this issue.


Merged it in, thanks!

1 Like