Problem Description
I was recently setting up a new CDN service and configuring DISCOURSE_LONG_POLLING_BASE_URL
in app.yml
, for separating the long polling service to the original server.
But the message bus continues to make requests to β/β instead of respecting the configured long polling base URL.
Steps to Reproduce
- Configure
DISCOURSE_LONG_POLLING_BASE_URL
inapp.yml
with a custom CDN URL - Rebuild and start Discourse
- Verify that the frontend correctly reads the environment variable value
- Observe message bus network requests in browser dev tools
Some screenshots
Frontend correctly reading the setting:
Expected Behavior
Message bus should use the configured long_polling_base_url
setting for its requests when the setting is provided.
Actual Behavior
Message bus continues to make requests to β/β regardless of the DISCOURSE_LONG_POLLING_BASE_URL
configuration.
Root Cause
The issue is in app/assets/javascripts/discourse/app/instance-initializers/message-bus.js
.
The logic for setting messageBus.baseUrl
was not properly handling the long_polling_base_url
site setting, causing it to default to /
even when a custom URL was configured.
Fix
Iβve identified and fixed the issue in the message bus instance initializer. The fix ensures that when siteSettings.long_polling_base_url
is set and not equal to β/β, it properly configures the message bus base URL.
Verification
- Confirmed the frontend correctly reads the environment variable
- Fixed the message bus initialization logic to respect the setting
- All formatting checks pass
- Message bus now correctly uses the configured long polling base URL
This bug affects any Discourse installation using a custom CDN setup with long polling, preventing proper CDN utilization for message bus requests.
Thanks to @David_Ghost, please head over to our discussion here: