Merge remote-tracking branch 'origin/v2.x' into v2.x

pull/79/head
猿小天 2022-11-25 17:07:23 +08:00
commit b42ac3c8e6
2 changed files with 3 additions and 5 deletions

View File

@ -23,7 +23,7 @@ server {
rewrite ^/api/(.*)$ /$1 break; #重写 rewrite ^/api/(.*)$ /$1 break; #重写
proxy_pass http://177.8.0.12:8000/; # 设置代理服务器的协议和地址 proxy_pass http://177.8.0.12:8000/; # 设置代理服务器的协议和地址
} }
location /ws { location /api/ws {
proxy_http_version 1.1; proxy_http_version 1.1;
proxy_set_header Host $host; proxy_set_header Host $host;
proxy_set_header X-Real-Ip $remote_addr; proxy_set_header X-Real-Ip $remote_addr;

View File

@ -84,15 +84,13 @@ util.wsBaseURL = function () {
baseURL = location.protocol + '//' + location.hostname + (location.port ? ':' : '') + location.port + baseURL baseURL = location.protocol + '//' + location.hostname + (location.port ? ':' : '') + location.port + baseURL
} }
} else if (param !== '' || baseURL.startsWith('/')) { } 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('/')) { if (!baseURL.endsWith('/')) {
baseURL += '/' baseURL += '/'
} }
if (baseURL.startsWith('http')) { if (baseURL.startsWith('http')) { // https 也默认会被替换成 wss
baseURL = baseURL.replace('http', 'ws') baseURL = baseURL.replace('http', 'ws')
} else if (baseURL.startsWith('https')) {
baseURL = baseURL.replace('https', 'wss')
} }
return baseURL return baseURL
} }