From fef55a48caf52518817c115eaf843c32bedc027c Mon Sep 17 00:00:00 2001
From: Evan Feenstra <evan@evanfeenstra.com>
Date: Sun, 8 Sep 2019 14:45:49 -0500
Subject: [PATCH] fix ws/wss for https://

---
 plugins/ui/files.go       | 6 +++++-
 plugins/ui/src/js/main.js | 6 +++++-
 2 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/plugins/ui/files.go b/plugins/ui/files.go
index 9bd67d4b..3d361194 100644
--- a/plugins/ui/files.go
+++ b/plugins/ui/files.go
@@ -494,8 +494,12 @@ Vue.component('empty-icon', {
       this.show()
       this.loggedIn = true
       this.selectedTab = 'Logs'
+      let wsProtocol = 'wss:'
+      if (location.protocol != 'https:') {
+        wsProtocol = 'ws:'
+      }
       this.ws = new WebSocket(
-        api.addToken('ws://'+window.location.host+'/ws')
+        api.addToken(wsProtocol+'//'+window.location.host+'/ws')
       )
       this.ws.onopen = (e) => { this.connected=true }
       this.ws.onclose = (e) => { this.connected=false }
diff --git a/plugins/ui/src/js/main.js b/plugins/ui/src/js/main.js
index 17f5a388..d6266b39 100644
--- a/plugins/ui/src/js/main.js
+++ b/plugins/ui/src/js/main.js
@@ -34,8 +34,12 @@ new Vue({
       this.show()
       this.loggedIn = true
       this.selectedTab = 'Logs'
+      let wsProtocol = 'wss:'
+      if (location.protocol != 'https:') {
+        wsProtocol = 'ws:'
+      }
       this.ws = new WebSocket(
-        api.addToken('ws://'+window.location.host+'/ws')
+        api.addToken(wsProtocol+'//'+window.location.host+'/ws')
       )
       this.ws.onopen = (e) => { this.connected=true }
       this.ws.onclose = (e) => { this.connected=false }
-- 
GitLab