From a8f8e09f9592e9ccba3e97f2f79d614eb94055be Mon Sep 17 00:00:00 2001 From: samlm0 <9084029+samlm0@users.noreply.github.com> Date: Fri, 19 Jan 2024 04:48:47 +0000 Subject: [PATCH] fix: make shell feature can work behind web proxy --- backend/als/controller/shell/shell.go | 4 ++++ ui/src/components/Utilities/Shell.vue | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/backend/als/controller/shell/shell.go b/backend/als/controller/shell/shell.go index 7b3ed77..34ca6d2 100644 --- a/backend/als/controller/shell/shell.go +++ b/backend/als/controller/shell/shell.go @@ -2,6 +2,8 @@ package shell import ( "context" + "fmt" + "net/http" "os" "os/exec" "strconv" @@ -19,8 +21,10 @@ var upgrader = websocket.Upgrader{ } func HandleNewShell(c *gin.Context) { + upgrader.CheckOrigin = func(r *http.Request) bool { return true } conn, err := upgrader.Upgrade(c.Writer, c.Request, nil) if err != nil { + fmt.Println(err) return } defer conn.Close() diff --git a/ui/src/components/Utilities/Shell.vue b/ui/src/components/Utilities/Shell.vue index 2c0e015..4317491 100644 --- a/ui/src/components/Utilities/Shell.vue +++ b/ui/src/components/Utilities/Shell.vue @@ -39,7 +39,7 @@ onMounted(() => { const url = new URL(location.href) const protocol = url.protocol == 'http:' ? 'ws:' : 'wss:' websocket = new WebSocket( - protocol + '//' + url.host + '/session/' + useAppStore().sessionId + '/shell' + protocol + '//' + url.host + url.pathname + 'session/' + useAppStore().sessionId + '/shell' ) websocket.binaryType = 'arraybuffer' websocket.addEventListener('message', (event) => {