summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorembeddedt <42941056+embeddedt@users.noreply.github.com>2021-05-13 04:13:34 -0400
committerGitHub <noreply@github.com>2021-05-13 10:13:34 +0200
commit86741ad489c3ee2d519eeb071be846721b90412c (patch)
tree83485cc428446815a4f5d241b07c2b21a32ba0e0
parent56a46f5cae73e2362d6ab9b1741e51361d753b30 (diff)
downloadopenttd-86741ad489c3ee2d519eeb071be846721b90412c.tar.xz
Fix: [Emscripten] Force secure WebSockets over HTTPS (#9248)
-rw-r--r--os/emscripten/pre.js10
1 files changed, 9 insertions, 1 deletions
diff --git a/os/emscripten/pre.js b/os/emscripten/pre.js
index 82664004e..2fb641017 100644
--- a/os/emscripten/pre.js
+++ b/os/emscripten/pre.js
@@ -9,7 +9,15 @@ Module['websocket'] = { url: function(host, port, proto) {
* If you run your own server you can setup your own WebSocket proxy in
* front of it and let people connect to your server via the proxy. You
* are best to add another "if" statement as above for this. */
- return null;
+
+ if (location.protocol === 'https:') {
+ /* Insecure WebSockets do not work over HTTPS, so we force
+ * secure ones. */
+ return 'wss://';
+ } else {
+ /* Use the default provided by Emscripten. */
+ return null;
+ }
} };
Module.preRun.push(function() {