mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2025-12-23 06:42:41 +00:00
refactor: ensure proper WebSocket URL construction by normalizing basePath
This commit is contained in:
parent
cf1b39c714
commit
ca4d2e1e90
1 changed files with 8 additions and 1 deletions
|
|
@ -19,7 +19,14 @@ class WebSocketClient {
|
||||||
}
|
}
|
||||||
|
|
||||||
const protocol = window.location.protocol === 'https:' ? 'wss:' : 'ws:';
|
const protocol = window.location.protocol === 'https:' ? 'wss:' : 'ws:';
|
||||||
const wsUrl = `${protocol}//${window.location.host}${this.basePath}ws`;
|
// Ensure basePath ends with '/' for proper URL construction
|
||||||
|
let basePath = this.basePath || '';
|
||||||
|
if (basePath && !basePath.endsWith('/')) {
|
||||||
|
basePath += '/';
|
||||||
|
}
|
||||||
|
const wsUrl = `${protocol}//${window.location.host}${basePath}ws`;
|
||||||
|
|
||||||
|
console.log('WebSocket connecting to:', wsUrl, 'basePath:', this.basePath);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
this.ws = new WebSocket(wsUrl);
|
this.ws = new WebSocket(wsUrl);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue