From d7a66e4f15883df89c0f750ba86287cbd9e8b14c Mon Sep 17 00:00:00 2001 From: David Bushong Date: Sat, 9 Mar 2019 09:23:51 -0800 Subject: [PATCH] Open websocket on same path as page (#149) 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 f9094383..18fc8322 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;