Ensure we use proper URL to connect to websocket

environments/review-docs-325-y-jtu23o/deployments/17
Eliot Berriot 2018-06-23 19:41:58 +02:00
rodzic 7d60155b0f
commit 63dd5b2f06
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: DD6965E2476E5C27
2 zmienionych plików z 8 dodań i 8 usunięć

Wyświetl plik

@ -54,19 +54,16 @@ export default {
state.events = value
},
instanceUrl: (state, value) => {
if (value && !value.endsWith('/')) {
value = value + '/'
}
state.instanceUrl = value
if (!value) {
axios.defaults.baseURL = null
return
}
let apiUrl
let suffix = 'api/v1/'
if (state.instanceUrl.endsWith('/')) {
apiUrl = state.instanceUrl + suffix
} else {
apiUrl = state.instanceUrl + '/' + suffix
}
axios.defaults.baseURL = apiUrl
axios.defaults.baseURL = state.instanceUrl + suffix
}
},
getters: {

Wyświetl plik

@ -78,8 +78,11 @@ export default {
// let token = 'test'
const bridge = new WebSocketBridge()
this.bridge = bridge
let url = this.$store.getters['instance/absoluteUrl'](`api/v1/instance/activity?token=${token}`)
url = url.replace('http://', 'ws://')
url = url.replace('https://', 'wss://')
bridge.connect(
`/api/v1/instance/activity?token=${token}`,
url,
null,
{reconnectInterval: 5000})
bridge.listen(function (event) {