From 7087d553b0ded5a9f979f57c4ff915515f81e6d5 Mon Sep 17 00:00:00 2001 From: 3nd3r Date: Sat, 3 Jan 2026 09:54:58 -0600 Subject: [PATCH] Use same-origin MP3 stream URL for proxies --- script.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/script.js b/script.js index 2263aae..d87db82 100644 --- a/script.js +++ b/script.js @@ -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}`);