fix: avoid websocket token leakage in logs
This commit is contained in:
@@ -169,21 +169,22 @@ export class WebSocketManager {
|
||||
return;
|
||||
}
|
||||
|
||||
// 构建带token的URL
|
||||
const separator = this.config.url.includes('?') ? '&' : '?';
|
||||
const wsUrl = `${this.config.url}${separator}token=${encodeURIComponent(token)}`;
|
||||
const wsUrl = this.config.url;
|
||||
const protocols = Array.isArray(this.config.protocols)
|
||||
? [...this.config.protocols]
|
||||
: this.config.protocols
|
||||
? [this.config.protocols]
|
||||
: [];
|
||||
protocols.unshift('access_token', token);
|
||||
|
||||
console.log(
|
||||
'Connecting to WebSocket:',
|
||||
wsUrl.replace(/token=[^&]+/, 'token=***'),
|
||||
);
|
||||
console.log('Connecting to WebSocket:', wsUrl);
|
||||
console.log('WebSocket URL详情:', {
|
||||
originalUrl: this.config.url,
|
||||
finalUrl: wsUrl.replace(/token=[^&]+/, 'token=***'),
|
||||
finalUrl: wsUrl,
|
||||
isDev: import.meta.env.DEV,
|
||||
});
|
||||
|
||||
this.ws = new WebSocket(wsUrl, this.config.protocols);
|
||||
this.ws = new WebSocket(wsUrl, protocols);
|
||||
|
||||
this.ws.addEventListener('open', (event) => {
|
||||
console.log('WebSocket连接已建立');
|
||||
|
||||
Reference in New Issue
Block a user