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]()
|
this[EVENT.CONNECTING]()
|
||||||
|
|
||||||
try {
|
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.emit('debug', `connecting to ${this._ws.url}`)
|
||||||
this._ws.onmessage = this.onMessage.bind(this)
|
this._ws.onmessage = this.onMessage.bind(this)
|
||||||
this._ws.onerror = (event) => this.onError.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) {
|
init(vue: Vue) {
|
||||||
const url =
|
const url =
|
||||||
process.env.NODE_ENV === 'development'
|
process.env.NODE_ENV === 'development'
|
||||||
? `ws://${location.host.split(':')[0]}:${process.env.VUE_APP_SERVER_PORT}/`
|
? `ws://${location.host.split(':')[0]}:${process.env.VUE_APP_SERVER_PORT}/ws`
|
||||||
: `${/https/gi.test(location.protocol) ? 'wss' : 'ws'}://${location.host}/`
|
: location.href.replace(/^http/, 'ws').replace(/\/$/, '')+'/ws'
|
||||||
|
|
||||||
this.initWithURL(vue, url)
|
this.initWithURL(vue, url)
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user