From 89f53857e6377828cccf81ca3fefce3bd6f7557c 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/_ibs/Operations/VirtualMedia/VirtualMedia.vue | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

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

diff --git a/src/views/_ibs/Operations/VirtualMedia/VirtualMedia.vue b/src/views/_ibs/Operations/VirtualMedia/VirtualMedia.vue
index bfd87b8a..320f0030 100644
--- a/src/views/_ibs/Operations/VirtualMedia/VirtualMedia.vue
+++ b/src/views/_ibs/Operations/VirtualMedia/VirtualMedia.vue
@@ -150,12 +150,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

