Discourse-Einbettung fehlgeschlagen (Referer verwechselt)

Hello,

I’m in the process of embedding Discourse in a Mediawiki instance, and I seem to have a strange issue with it.

When I link my wiki page to an existing discourse topic, everything works like a charm:

window.DiscourseEmbed = { discourseUrl: 'https://forum.dev.tripleperformance.fr/',|
                          topicId: 18};

But when I try to create the topic it fails:

window.DiscourseEmbed = { discourseUrl: 'https://forum.dev.tripleperformance.fr/',|
                          discourseEmbedUrl = 'https:' + mw.config.get('wgServer') + '/wiki/' + mw.config.get('wgPageName')};

The iframe is loaded a first time with:

<meta id="data-embedded" data-referer="https://wiki.dev.tripleperformance.fr/wiki/Sandbox">

Then, after 30 seconds (caused by the meta http-equiv="refresh" in the iframe), the iframe reloads with:

<meta id="data-embedded" data-referer="https://forum.dev.tripleperformance.fr/embed/comments?embed_url=https%3A%2F%2Fwiki.dev.tripleperformance.fr%2Fwiki%2FSandbox">`

At this point, there’s an error in the console:

Failed to execute 'postMessage' on 'DOMWindow': The target origin provided ('https://forum.dev.tripleperformance.fr') does not match the recipient window's origin ('https://wiki.dev.tripleperformance.fr').

That’s probably because the referer in the data-embedded attribute is now self and not the parent page (which might actually be expected since the initiator of the refresh is self).

Note: I’m on a development machine which is slow due to docker and everything. It’s quite possible that I’m in a race condition or something…?

For what it’s worth, I’ve tried to create a post in the forum with a link to a wiki page, and it managed to resolve it (the embed is properly displayed). I also tried to curl the URL from within the container with success. I don’t understand why the new topic is not created right away…

hello Bertrand!
Hopefully this issue is solved for you by now, but if not, you might want to try the code in the test-passed branch, which contains a fix from today for a problem with similar symptoms.

Said problem was introduced in the code AFTER August 25th when you reported this, so it’s unlikely this is the exact same issue.
Still, if this is unresolved for you, you might want to give it a try.

Cheers!

3 „Gefällt mir“

Hallo Leonardo,

Danke dafür. Ich habe es gerade versucht – mit nicht viel mehr Erfolg. Ich habe mich aber nicht zu sehr damit beschäftigt, da diese Art der Integration nicht zu unserer Plattform passt (ich ziehe es vor, dass das Thema bedarfsgesteuert durch etwas Code erstellt wird und nicht für jede Seite, die wir auf der Plattform haben).

Tut mir leid, das zu hören, aber es war einen Versuch wert :slight_smile:
Prost!