From 0dcfedb4dcee4cbae62909e4f79dd4d4e889ae64 Mon Sep 17 00:00:00 2001 From: lejianwen <84855512@qq.com> Date: Sun, 16 Feb 2025 12:41:32 +0800 Subject: [PATCH] fix(webclient)!: Webclient path is `/ws/(relay|id)` (#73 #143 #140) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Webclient 的反代引发了很多问题,现在将在HTTPS下的path固定为`/ws/(relay|id)` --- Closes: #143 #140 --- resources/web2/js/dist/index.js | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/resources/web2/js/dist/index.js b/resources/web2/js/dist/index.js index 3e67b17..bd97545 100644 --- a/resources/web2/js/dist/index.js +++ b/resources/web2/js/dist/index.js @@ -11090,16 +11090,21 @@ function R4(u = !1) { function getUriFromRs(uri, isRelay = false, roffset = 0) { const p = isHttps() ? "wss://" : "ws://" const [domain, uriport] = uri.split(":") - if (isHttps() && (!uriport)) { - return p + domain + "/ws/" + (isRelay ? "relay" : "id"); + if (!isHttps()) { + // http 直接走端口 + const port = uriport ? parseInt(uriport) : defaultIdServerPort; + return p + domain + ":" + port + (isRelay ? roffset || 3 : 2) } - if (uriport) { - const port = parseInt(uriport); - uri = domain + ":" + (port + (isRelay ? roffset || 3 : 2)) - } else uri += ":" + (defaultIdServerPort + (isRelay ? 3 : 2)); - return p + uri + // https 分情况 + if (!window.location.port) { + // 443 + return p + domain + "/ws/" + (isRelay ? "relay" : "id") + } + // 非443 + return p + domain + ":" + window.location.port + "/ws/" + (isRelay ? "relay" : "id") } + function isHttps() { return window.location.protocol === "https:" }