Fix WebSocket protocol detecton under HTTPS

This commit is contained in:
David Zhuang
2023-02-18 17:51:01 -05:00
parent 8ab7c4db4d
commit 59abd76966

View File

@@ -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() {