Fix WebSocket protocol handling based on page protocol
This commit is contained in:
@ -1,6 +1,6 @@
|
|||||||
if (!window.mySocket) {
|
if (!window.mySocket) {
|
||||||
const wsProtocol = window.location.protocol === 'https:' ? 'wss:' : 'ws:';
|
const wsProtocol = window.location.protocol === 'https:' ? 'wss:' : 'ws:';
|
||||||
window.mySocket = new WebSocket(`${wsProtocol}://${window.location.host}/user`);
|
window.mySocket = new WebSocket(`${wsProtocol}//${window.location.host}/user`);
|
||||||
|
|
||||||
window.mySocket.onopen = function(event) {
|
window.mySocket.onopen = function(event) {
|
||||||
console.log('WebSocket is open now.');
|
console.log('WebSocket is open now.');
|
||||||
|
Reference in New Issue
Block a user