The discussion revolves around the Message-bus feature in Discourse chat. jandres is trying to integrate this feature into his mobile application and is experiencing issues with duplicated headers when making requests from an external site or mobile app. He is getting an error due to CORS policy.
jandres is using the example provided by sam as a source of inspiration. sam points out that headers are set up in the 004-message_bus.rb file, but jandres is seeking a way to use the headers already set by the Discourse config to avoid duplication.
jandres wants to use the message_bus as an external client using the JavaScript library provided by sam. However, sam advises that this is too custom and jandres will have to debug through things himself.
jandres found an example of someone who successfully implemented the message_bus feature in a similar way and is seeking guidance on how to achieve this.
I am trying to understand how works the message-bus feature used by discourse to stay online with new messages and events. Specifically I am insterested in how is used in the recent Discourse chat plugin.
Making some reverse ingeniering I see that when I enter to chatroom, everytime the message-bus make a poll via “https://mysite.com/message-bus/client_id/poll” then the request headers are duplicated for example:
So that works into my site but when I try to make a request from an external site or mobile app, then I get the error:
Access to XMLHttpRequest at 'https://forum-dev.srepe.com/message-bus/f6e2303ff7704f608ef2b821fe210e90/poll'
from origin 'http://localhost:8100' has been blocked by CORS policy:
The 'Access-Control-Allow-Origin' header contains multiple values
'https://forum-dev.srepe.com, *', but only one is allowed.
So, if I understand the message_bus set their own “Headers” ? There are any way to use the “Headers” already set by the config of Discourse, at least those with CORS behaviour ?
I seek to avoid duplicate “headers” when using message_bus. This allow me to make request outside the forum site
I am afraid this is all too custom for me to provide advice here, totally appreciate more people using message bus, but you you are going to have to debug through things here.