Set Mopidy WebSocket URL according to document location

for correct nginx folder redirection
This commit is contained in:
Andrey Perminov 2020-03-10 16:02:22 -07:00
parent 7c42146b16
commit 46b6983f72

View File

@ -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