Browse Source

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

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

---

Closes: #143 #140
lejianwen 11 months ago
parent
commit
0dcfedb4dc
1 changed files with 12 additions and 7 deletions
  1. 12 7
      resources/web2/js/dist/index.js

+ 12 - 7
resources/web2/js/dist/index.js

@@ -11090,16 +11090,21 @@ function R4(u = !1) {
11090 11090
 function getUriFromRs(uri, isRelay = false, roffset = 0) {
11091 11091
     const p = isHttps() ? "wss://" : "ws://"
11092 11092
     const [domain, uriport] = uri.split(":")
11093
-    if (isHttps() && (!uriport)) {
11094
-        return p + domain + "/ws/" + (isRelay ? "relay" : "id");
11093
+    if (!isHttps()) {
11094
+        // http 直接走端口
11095
+        const port = uriport ? parseInt(uriport) : defaultIdServerPort;
11096
+        return p + domain + ":" + port + (isRelay ? roffset || 3 : 2)
11095 11097
     }
11096
-    if (uriport) {
11097
-        const port = parseInt(uriport);
11098
-        uri = domain + ":" + (port + (isRelay ? roffset || 3 : 2))
11099
-    } else uri += ":" + (defaultIdServerPort + (isRelay ? 3 : 2));
11100
-    return p + uri
11098
+    // https 分情况
11099
+    if (!window.location.port) {
11100
+        // 443
11101
+        return p + domain + "/ws/" + (isRelay ? "relay" : "id")
11102
+    }
11103
+    // 非443
11104
+    return p + domain + ":" + window.location.port + "/ws/" + (isRelay ? "relay" : "id")
11101 11105
 }
11102 11106
 
11107
+
11103 11108
 function isHttps() {
11104 11109
     return window.location.protocol === "https:"
11105 11110
 }