Ensure we use proper URL to connect to websocket
This commit is contained in:
parent
7d60155b0f
commit
63dd5b2f06
|
@ -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: {
|
||||
|
|
|
@ -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) {
|
||||
|
|
Loading…
Reference in New Issue