Fixes for running with https frontend (#20)

* use browser protocol

* Update zz_generated.static.go

* set host args with proper port

* Update zz_generated.static.go

* use proper protocol for the websocket
This commit is contained in:
Chris Campbell
2020-11-22 09:34:26 -07:00
committed by GitHub
parent 83d0260c6f
commit b64c44e6ac
3 changed files with 15 additions and 15 deletions

View File

@ -135,7 +135,7 @@
localStorage.setItem("playerName", inputPlayerName.value);
}
host = document.location.host
if (!host.includes(":")) { host = host + ":80" }
if (!host.includes(":")) { host = host + (window.location.protocol == 'https:' ? ":443" : ":80") }
var args = ['+set', 'fs_cdn', host, '+connect', host];
args.push.apply(args, ['+set', 'cl_allowDownload', '1'])
args.push.apply(args, ['+set', 'cl_timeout', '15'])

8
public/ioquake3.js vendored
View File

@ -15225,7 +15225,7 @@ function copyTempDouble(ptr) {
//var root = SYSC.GetCDN();
var root = Pointer_stringify(_Cvar_VariableString(allocate(intArrayFromString('fs_cdn'), 'i8', ALLOC_STACK)));
var name = asset.name.replace(/(.+\/|)(.+?)$/, '$1' + asset.checksum + '-$2');
var url = 'http://' + root + '/assets/' + name;
var url = document.location.protocol + '//' + root + '/assets/' + name;
SYS.DoXHR(url, {
dataType: 'arraybuffer',
@ -15274,9 +15274,9 @@ function copyTempDouble(ptr) {
var fs_cdn = Pointer_stringify(_Cvar_VariableString(allocate(intArrayFromString('fs_cdn'), 'i8', ALLOC_STACK)));
var fs_game = Pointer_stringify(_Cvar_VariableString(allocate(intArrayFromString('fs_game'), 'i8', ALLOC_STACK)));
var com_basegame = Pointer_stringify(_Cvar_VariableString(allocate(intArrayFromString('com_basegame'), 'i8', ALLOC_STACK)));
var url = 'http://' + fs_cdn + '/assets/manifest.json';
var url = document.location.protocol + '//' + fs_cdn + '/assets/manifest.json';
SYS.DoXHR('http://' + fs_cdn + '/info', {
SYS.DoXHR(document.location.protocol + '//' + fs_cdn + '/info', {
dataType: 'json',
onload: function (err, info) {
var mapname = info["mapname"];
@ -16601,7 +16601,7 @@ function copyTempDouble(ptr) {
} else {
// create the actual websocket object and connect
try {
var url = 'ws://' + addr + ':' + port;
var url = (window.location.protocol == 'https:' ? "wss://" : "ws://") + addr + ':' + port;
// the node ws library API is slightly different than the browser's
var opts = ENVIRONMENT_IS_NODE ? {headers: {'websocket-protocol': ['binary']}} : ['binary'];
// If node we use the ws library.

File diff suppressed because one or more lines are too long