Skip to content

Commit 4f31396

Browse files
committed
frontend/x11: select wss vs ws for https vs http -- useful for local dev!
1 parent 8557638 commit 4f31396

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/packages/frontend/frame-editors/x11-editor/xpra-client.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -156,17 +156,18 @@ export class XpraClient extends EventEmitter {
156156
// Get origin, but with http[s] stripped.
157157
// Do not use window.location.hostname, since that doesn't
158158
// include the port, if there is one.
159-
let origin = window.location.origin;
159+
const { origin, protocol: pageProtocol } = window.location;
160160
const i = origin.indexOf(":");
161-
origin = origin.slice(i);
161+
const originTail = origin.slice(i);
162+
const wsProtocol = pageProtocol === "https:" ? "wss" : "ws";
162163

163164
const path = join(
164165
appBasePath,
165166
this.options.project_id,
166167
"server",
167168
`${port}`,
168169
);
169-
const uri = `wss${origin}${path}`;
170+
const uri = `${wsProtocol}${originTail}${path}`;
170171
const dpi = Math.round(BASE_DPI * window.devicePixelRatio);
171172
return { uri, dpi };
172173
}

0 commit comments

Comments
 (0)