relative websocket URL.
This commit is contained in:
parent
afb416ea57
commit
69e7990afb
@ -59,7 +59,7 @@ export abstract class BaseClient extends EventEmitter<BaseEvents> {
|
||||
this[EVENT.CONNECTING]()
|
||||
|
||||
try {
|
||||
this._ws = new WebSocket(`${url}ws?password=${password}`)
|
||||
this._ws = new WebSocket(`${url}?password=${encodeURIComponent(password)}`)
|
||||
this.emit('debug', `connecting to ${this._ws.url}`)
|
||||
this._ws.onmessage = this.onMessage.bind(this)
|
||||
this._ws.onerror = (event) => this.onError.bind(this)
|
||||
|
@ -33,8 +33,8 @@ export class NekoClient extends BaseClient implements EventEmitter<NekoEvents> {
|
||||
init(vue: Vue) {
|
||||
const url =
|
||||
process.env.NODE_ENV === 'development'
|
||||
? `ws://${location.host.split(':')[0]}:${process.env.VUE_APP_SERVER_PORT}/`
|
||||
: `${/https/gi.test(location.protocol) ? 'wss' : 'ws'}://${location.host}/`
|
||||
? `ws://${location.host.split(':')[0]}:${process.env.VUE_APP_SERVER_PORT}/ws`
|
||||
: location.href.replace(/^http/, 'ws').replace(/\/$/, '')+'/ws'
|
||||
|
||||
this.initWithURL(vue, url)
|
||||
}
|
||||
|
Reference in New Issue
Block a user