修复HTTPS环境下WebSocket连接被拦截的问题
- WebSocket URL 根据页面协议自动选择 ws/wss - 使用 window.location.host 替代硬编码端口,适配内网穿透代理场景 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Fable 5
parent
4522421293
commit
e7edb56107
@@ -139,7 +139,7 @@ export default function LoginTasksPage() {
|
||||
message.success(`已创建登录任务,共 ${result.count} 个账号`);
|
||||
|
||||
// 连接 WebSocket
|
||||
const wsUrl = `ws://${window.location.hostname}:8000/api/login/ws/login/${result.batch_id}`;
|
||||
const wsUrl = `${window.location.protocol === 'https:' ? 'wss' : 'ws'}://${window.location.host}/api/login/ws/login/${result.batch_id}`;
|
||||
const ws = new WebSocket(wsUrl);
|
||||
wsRef.current = ws;
|
||||
setWsConnected(true);
|
||||
|
||||
Reference in New Issue
Block a user