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;
|
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}`);
|
||||||
|
|||||||
Reference in New Issue
Block a user