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