فشل تضمين Discourse (اختلاط المرجع)

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 إعجابات

مرحباً ليوناردو،

شكراً لك على هذا. لقد جربت للتو - دون نجاح كبير. لم أتعمق في الأمر كثيراً، حيث أن هذا النوع من التكامل لن يناسب منصتنا (أفضل أن يتم إنشاء الموضوع عند الطلب من خلال القليل من التعليمات البرمجية وليس لكل صفحة لدينا في المنصة).

يؤسفني سماع ذلك، لكنه كان يستحق المحاولة :slight_smile:
تحياتي!