diff --git a/client-src/utils/createSocketURL.js b/client-src/utils/createSocketURL.js index b49ae98b78..168c3b6c9e 100644 --- a/client-src/utils/createSocketURL.js +++ b/client-src/utils/createSocketURL.js @@ -21,7 +21,7 @@ function createSocketURL(parsedURL) { hostname = self.location.hostname; } - let socketURLProtocol = parsedURL.protocol || "ws:"; + let socketURLProtocol = parsedURL.protocol || self.location.protocol; // When https is used in the app, secure web sockets are always necessary because the browser doesn't accept non-secure web sockets. if ( diff --git a/test/client/utils/createSocketURL.test.js b/test/client/utils/createSocketURL.test.js index 01e2feadb3..393ed96a50 100644 --- a/test/client/utils/createSocketURL.test.js +++ b/test/client/utils/createSocketURL.test.js @@ -55,7 +55,7 @@ describe("'createSocketURL' function ", () => { ["?hostname=%3A%3A", "http://example.com:8080", "ws://example.com:8080/ws"], ["?hostname=%3A%3A1", "http://example.com:8080", "ws://[::1]:8080/ws"], - ["?hostname=%3A%3A1", "https://example.com:8080", "ws://[::1]:8080/ws"], + ["?hostname=%3A%3A1", "https://example.com:8080", "wss://[::1]:8080/ws"], [ "?hostname=%3A%3A", "https://example.com:8080",