From 7ecc156c07579cbba4480831051a753403d21f75 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E5=BC=BA?= <1206709430@qq.com> Date: Fri, 25 Nov 2022 15:58:30 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E5=8A=9F=E8=83=BD=E5=8F=98=E5=8C=96:=20wsB?= =?UTF-8?q?aseURL?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- web/src/libs/util.js | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/web/src/libs/util.js b/web/src/libs/util.js index 735d0bb..7627529 100644 --- a/web/src/libs/util.js +++ b/web/src/libs/util.js @@ -84,15 +84,13 @@ util.wsBaseURL = function () { baseURL = location.protocol + '//' + location.hostname + (location.port ? ':' : '') + location.port + baseURL } } else if (param !== '' || baseURL.startsWith('/')) { - baseURL = (location.protocol === 'https' ? 'wss://' : 'ws://') + location.hostname + (location.port ? ':' : '') + location.port + baseURL + baseURL = (location.protocol === 'https:' ? 'wss://' : 'ws://') + location.hostname + (location.port ? ':' : '') + location.port + baseURL } if (!baseURL.endsWith('/')) { baseURL += '/' } - if (baseURL.startsWith('http')) { + if (baseURL.startsWith('http')) { // https 也默认会被替换成 wss baseURL = baseURL.replace('http', 'ws') - } else if (baseURL.startsWith('https')) { - baseURL = baseURL.replace('https', 'wss') } return baseURL } From 91146e80daa441382ce47c129d4a11f80b1cfc4c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E5=BC=BA?= <1206709430@qq.com> Date: Fri, 25 Nov 2022 16:05:34 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E5=8A=9F=E8=83=BD=E5=8F=98=E5=8C=96:=20web?= =?UTF-8?q?socket=20nginx=20=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docker_env/nginx/my.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker_env/nginx/my.conf b/docker_env/nginx/my.conf index 7a40d6b..dc9fccc 100644 --- a/docker_env/nginx/my.conf +++ b/docker_env/nginx/my.conf @@ -23,7 +23,7 @@ server { rewrite ^/api/(.*)$ /$1 break; #重写 proxy_pass http://177.8.0.12:8000/; # 设置代理服务器的协议和地址 } - location /ws { + location /api/ws { proxy_http_version 1.1; proxy_set_header Host $host; proxy_set_header X-Real-Ip $remote_addr;