Browse Source

refactor: typo correction in websocket connection

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

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

@ -10,22 +10,24 @@ export default function({
let socket let socket
const init = async(token) => { const init = async(token) => {
if (socket) { try {
socket.disconnect() if (socket) {
} socket.disconnect()
const isUrl = $axios.defaults.baseURL.startsWith('http') }
const url = isUrl ? $axios.defaults.baseURL : window.location.origin const isUrl = $axios.defaults.baseURL.startsWith('http')
const path = isUrl ? undefined : ($axios.defaults.baseURL === '..' ? window.location.path.split('/').slice(0, -1).join('/') : $axios.defaults.baseURL) const url = isUrl ? $axios.defaults.baseURL : window.location.origin
const path = isUrl ? undefined : ($axios.defaults.baseURL === '..' ? window.location.pathname.split('/').slice(0, -1).join('/') : $axios.defaults.baseURL)
socket = io(url, { socket = io(url, {
path, path,
extraHeaders: { 'xc-auth': token } extraHeaders: { 'xc-auth': token }
}) })
socket.on('connect_error', () => { socket.on('connect_error', () => {
socket.disconnect() socket.disconnect()
socket = null socket = null
}) })
} catch { }
} }
app.router.onReady(() => { app.router.onReady(() => {

Loading…
Cancel
Save