From f47ddcfeaa957dd6571b35e6ba7b761892f186db Mon Sep 17 00:00:00 2001
From: Alexandr Ilenko <AIlenko@IBS.RU>
Date: Mon, 22 Aug 2022 18:33:14 +0300
Subject: [SILABMC-280] Fix: use wsS only when httpS

---
 src/views/Operations/VirtualMedia/VirtualMedia.vue | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

(limited to 'src/views/Operations/VirtualMedia/VirtualMedia.vue')

diff --git a/src/views/Operations/VirtualMedia/VirtualMedia.vue b/src/views/Operations/VirtualMedia/VirtualMedia.vue
index 8a3d5add..bbf6eb39 100644
--- a/src/views/Operations/VirtualMedia/VirtualMedia.vue
+++ b/src/views/Operations/VirtualMedia/VirtualMedia.vue
@@ -136,12 +136,9 @@ export default {
   methods: {
     startVM(device) {
       const token = this.$store.getters['authentication/token'];
-      device.nbd = new NbdServer(
-        `wss://${window.location.host}${device.websocket}`,
-        device.file,
-        device.id,
-        token
-      );
+      const url = new URL(device.websocket, window.location.href);
+      url.protocol = url.protocol.replace('http', 'ws');
+      device.nbd = new NbdServer(url, device.file, device.id, token);
       device.nbd.socketStarted = () =>
         this.successToast(this.$t('pageVirtualMedia.toast.serverRunning'));
       device.nbd.errorReadingFile = () =>
-- 
cgit v1.2.3

