From 46b6983f72f5211bb8982f3d53bf8db939a09210 Mon Sep 17 00:00:00 2001 From: Andrey Perminov Date: Tue, 10 Mar 2020 16:02:22 -0700 Subject: [PATCH] Set Mopidy WebSocket URL according to document location for correct nginx folder redirection --- mopidy_musicbox_webclient/static/js/gui.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/mopidy_musicbox_webclient/static/js/gui.js b/mopidy_musicbox_webclient/static/js/gui.js index aaafd49..1a372f4 100644 --- a/mopidy_musicbox_webclient/static/js/gui.js +++ b/mopidy_musicbox_webclient/static/js/gui.js @@ -565,7 +565,10 @@ $(document).ready(function (event) { $(window).resize(resizeMb).resize() // Connect to server - var websocketUrl = $(document.body).data('websocket-url') + //var websocketUrl = $(document.body).data('websocket-url') + var wsProto = "https:" === window.location.protocol ? "wss://" : "ws://"; + var websocketUrl = wsProto + window.location.hostname + + window.location.pathname.replace("musicbox_webclient", "mopidy").match(/.*\//) + "ws"; var connectOptions = {callingConvention: 'by-position-or-by-name'} if (websocketUrl) { connectOptions['webSocketUrl'] = websocketUrl