Message bus ignores DISCOURSE_LONG_POLLING_BASE_URL setting and always uses "/"

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

  1. Configure DISCOURSE_LONG_POLLING_BASE_URL in app.yml with a custom CDN URL
  2. Rebuild and start Discourse
  3. Verify that the frontend correctly reads the environment variable value
  4. 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.

Pull Request: FIX: Respect long_polling_base_url setting for message bus configuration by chenglu Β· Pull Request #34477 Β· discourse/discourse Β· GitHub

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:

1 Like