Use same-origin MP3 stream URL for proxies

This commit is contained in:
3nd3r
2026-01-03 09:54:58 -06:00
parent 9a53a33341
commit 7087d553b0

View File

@@ -1609,7 +1609,8 @@ function startListenerVUMeter() {
let currentStreamMimeType = null;
function getMp3FallbackUrl() {
return `${window.location.protocol}//${window.location.hostname}:5001/stream.mp3`;
// Use same-origin so this works behind reverse proxies (e.g., Cloudflare) where :5001 may not be reachable.
return `${window.location.origin}/stream.mp3`;
}
// Initialize SocketIO connection
@@ -1624,11 +1625,10 @@ function initSocket() {
window.location.hostname.startsWith('listen.') ||
urlParams.get('listen') === 'true';
// If someone opens listener mode on the DJ port (e.g. :5000?listen=true),
// force the Socket.IO connection to the listener backend (:5001).
const serverUrl = (isListenerMode && window.location.port !== '5001' &&
!window.location.hostname.startsWith('music.') &&
!window.location.hostname.startsWith('listen.'))
// If someone opens listener mode on the DJ dev port (:5000?listen=true),
// use the listener backend (:5001). For proxied deployments (Cloudflare),
// do NOT force a port (it may be blocked); stick to same-origin.
const serverUrl = (isListenerMode && window.location.port === '5000')
? `${window.location.protocol}//${window.location.hostname}:5001`
: window.location.origin;
console.log(`🔌 Initializing Socket.IO connection to: ${serverUrl}`);