refactor: ensure proper WebSocket URL construction by normalizing basePath

This commit is contained in:
lolka1333 2025-12-14 13:14:53 +01:00
parent cf1b39c714
commit ca4d2e1e90

View file

@ -19,7 +19,14 @@ class WebSocketClient {
}
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 {
this.ws = new WebSocket(wsUrl);