From 2da77d84489e133b895a2a4a6b494013346e8d25 Mon Sep 17 00:00:00 2001 From: LouisLam Date: Sat, 11 Sep 2021 14:37:05 +0800 Subject: [PATCH] fix ipv6 connection problem --- src/mixins/socket.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/mixins/socket.js b/src/mixins/socket.js index 22cc25bfd..9771db0d2 100644 --- a/src/mixins/socket.js +++ b/src/mixins/socket.js @@ -32,12 +32,14 @@ export default { created() { window.addEventListener("resize", this.onResize); + let protocol = (location.protocol === "https:") ? "wss://" : "ws://"; + let wsHost; const env = process.env.NODE_ENV || "production"; if (env === "development" || localStorage.dev === "dev") { - wsHost = ":3001" + wsHost = protocol + location.hostname + ":3001"; } else { - wsHost = "" + wsHost = protocol + location.host; } socket = io(wsHost, {