自适应HTTPS

This commit is contained in:
xrh0905 2021-09-25 19:42:13 +08:00 committed by GitHub
parent 81b0f8c0e0
commit 1a3d75a015
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -10,6 +10,19 @@ MCSERVER.WS_PROTOCOL = "ws://";
//HTTP 默认协议
MCSERVER.HTTP_PROTOCOL = "http://";
//自适应HTTPS
var protocolStr = document.location.protocol;
if(protocolStr == "http:")
{
MCSERVER.WS_PROTOCOL = 'ws://';
MCSERVER.HTTP_PROTOCOL = 'http://';
}
else if(protocolStr == "https:")
{
MCSERVER.WS_PROTOCOL = 'wss://';
MCSERVER.HTTP_PROTOCOL = 'https://';
}
//URL定位器
MCSERVER.URL = function (url, protocol) {
var _protocol = protocol || MCSERVER.HTTP_PROTOCOL;