fix(webclient)!: Webclient path is /ws/(relay|id) (#73 #143 #140)

Webclient 的反代引发了很多问题,现在将在HTTPS下的path固定为`/ws/(relay|id)`

---

Closes: #143 #140
This commit is contained in:
lejianwen
2025-02-16 12:41:32 +08:00
parent 918bf85a2d
commit 0dcfedb4dc

View File

@@ -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:"
}