check https for wss

This commit is contained in:
Ben Arc
2021-04-14 22:09:33 +01:00
parent 412ac8d110
commit 589a482faa
2 changed files with 34 additions and 14 deletions

View File

@@ -85,7 +85,7 @@
}, },
created: function () { created: function () {
console.log('{{ copilot.id }}') console.log('{{ copilot.id }}')
if (location.protocol !== 'https:') {
this.connection = new WebSocket( this.connection = new WebSocket(
'ws://' + 'ws://' +
document.domain + document.domain +
@@ -93,6 +93,16 @@
location.port + location.port +
'/copilot/ws/compose/{{ copilot.id }}' '/copilot/ws/compose/{{ copilot.id }}'
) )
} else {
this.connection = new WebSocket(
'wss://' +
document.domain +
':' +
location.port +
'/copilot/ws/compose/{{ copilot.id }}'
)
}
this.connection.addEventListener('open', function (event) { this.connection.addEventListener('open', function (event) {
this.connection.send('') this.connection.send('')
}) })

View File

@@ -170,13 +170,23 @@
created: function () { created: function () {
console.log('{{ copilot.id }}') console.log('{{ copilot.id }}')
if (location.protocol !== 'https:') {
this.connection = new WebSocket( this.connection = new WebSocket(
'ws://' + 'ws://' +
document.domain + document.domain +
':' + ':' +
location.port + location.port +
'/copilot/ws/panel/{{ copilot.id }}' '/copilot/ws/compose/{{ copilot.id }}'
) )
} else {
this.connection = new WebSocket(
'wss://' +
document.domain +
':' +
location.port +
'/copilot/ws/compose/{{ copilot.id }}'
)
}
this.connection.addEventListener('open', function (event) {}) this.connection.addEventListener('open', function (event) {})
this.connection.addEventListener('message', function (event) { this.connection.addEventListener('message', function (event) {