From 2d0c4218513581fd2c1dc8bc1ec059bb51cc7ec7 Mon Sep 17 00:00:00 2001 From: David Bushong Date: Fri, 8 Mar 2019 13:31:02 -0800 Subject: [PATCH] open websocket on same path as page This is the critical piece to let you serve code-server proxied under a path. Otherwise if you proxy e.g. `/editor/` thru to `http://localhost:8000`, everything works fine except the websocket connection is still opened to `/` --- packages/ide/src/fill/client.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/ide/src/fill/client.ts b/packages/ide/src/fill/client.ts index f90943835b56..18fc83221d63 100644 --- a/packages/ide/src/fill/client.ts +++ b/packages/ide/src/fill/client.ts @@ -91,8 +91,9 @@ class WebsocketConnection implements ReadWriteConnection { */ private async openSocket(): Promise { this.dispose(); + const wsProto = location.protocol === "https:" ? "wss" : "ws"; const socket = new WebSocket( - `${location.protocol === "https:" ? "wss" : "ws"}://${location.host}`, + `${wsProto}://${location.host}${location.pathname}`, ); socket.binaryType = "arraybuffer"; this.activeSocket = socket;