Skip to content

Commit 9455695

Browse files
dbushongkylecarbs
authored andcommitted
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 `/`
1 parent 402fd51 commit 9455695

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

packages/ide/src/fill/client.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,9 @@ class WebsocketConnection implements ReadWriteConnection {
9191
*/
9292
private async openSocket(): Promise<WebSocket> {
9393
this.dispose();
94+
const wsProto = location.protocol === "https:" ? "wss" : "ws";
9495
const socket = new WebSocket(
95-
`${location.protocol === "https:" ? "wss" : "ws"}://${location.host}`,
96+
`${wsProto}://${location.host}${location.pathname}`,
9697
);
9798
socket.binaryType = "arraybuffer";
9899
this.activeSocket = socket;

0 commit comments

Comments
 (0)