Browse Source

refactor: extract websocket and path based on axios baseurl

Signed-off-by: Pranav C <pranavxc@gmail.com>
pull/1668/head
Pranav C 3 years ago
parent
commit
12af229d8e
  1. 10
      packages/nc-gui/plugins/tele.js

10
packages/nc-gui/plugins/tele.js

@ -13,8 +13,12 @@ export default function({
if (socket) {
socket.disconnect()
}
const isUrl = $axios.defaults.baseURL.startsWith('http')
const url = isUrl ? $axios.defaults.baseURL : location.origin
const path = isUrl ? undefined : $axios.defaults.baseURL
socket = io($axios.defaults.baseURL, {
socket = io(url, {
path,
extraHeaders: { 'xc-auth': token }
})
@ -81,7 +85,9 @@ export default function({
})
store.watch(state => state.project.projectInfo && state.project.projectInfo.teleEnabled && state.users.token, (token) => {
if (token) { init(token) } else if (socket) {
if (token) {
init(token)
} else if (socket) {
socket.disconnect()
socket = null
}

Loading…
Cancel
Save