From 59abd76966e00a8c9d02013bbcbf37a248586a6b Mon Sep 17 00:00:00 2001 From: David Zhuang Date: Sat, 18 Feb 2023 17:51:01 -0500 Subject: [PATCH] Fix WebSocket protocol detecton under HTTPS --- frontend/src/utils.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/frontend/src/utils.ts b/frontend/src/utils.ts index c00da74..e85a106 100644 --- a/frontend/src/utils.ts +++ b/frontend/src/utils.ts @@ -74,7 +74,8 @@ export function toFormatArgs(codes: string[]): string { } export function getWebSocketEndpoint() { - return `ws://${localStorage.getItem('server-addr') || window.location.hostname}:${localStorage.getItem('server-port') || window.location.port}/ws-rpc` + const protocol = window.location.protocol === 'https:' ? 'wss' : 'ws' + return `${protocol}://${localStorage.getItem('server-addr') || window.location.hostname}:${localStorage.getItem('server-port') || window.location.port}/ws-rpc` } export function getHttpRPCEndpoint() {