forked from computertech/techdj
Use same-origin MP3 stream URL for proxies
This commit is contained in:
12
script.js
12
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}`);
|
||||
|
||||
Reference in New Issue
Block a user