解决当使用https连接ws时报错
This commit is contained in:
parent
e1fa4f090c
commit
4516e72b5c
@ -103,7 +103,8 @@
|
|||||||
};
|
};
|
||||||
},
|
},
|
||||||
async created() {
|
async created() {
|
||||||
const socket = new WebSocket("ws://" + window.location.host + "/ws");
|
const protocol = window.location.protocol === 'https:' ? 'wss://' : 'ws://';
|
||||||
|
const socket = new WebSocket(protocol + window.location.host + "/ws");
|
||||||
socket.onmessage = event => {
|
socket.onmessage = event => {
|
||||||
const feed = JSON.parse(event.data);
|
const feed = JSON.parse(event.data);
|
||||||
this.feeds.push(feed);
|
this.feeds.push(feed);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user