diff --git a/web/frontend/src/pages/LoginTasksPage.tsx b/web/frontend/src/pages/LoginTasksPage.tsx index bf3ef18..6ff314a 100644 --- a/web/frontend/src/pages/LoginTasksPage.tsx +++ b/web/frontend/src/pages/LoginTasksPage.tsx @@ -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); diff --git a/web/frontend/src/pages/ProxyPage.tsx b/web/frontend/src/pages/ProxyPage.tsx index ca96ab5..04224fb 100644 --- a/web/frontend/src/pages/ProxyPage.tsx +++ b/web/frontend/src/pages/ProxyPage.tsx @@ -2,7 +2,7 @@ import { useEffect, useState, useRef } from 'react'; import { Form, Input, Switch, Button, Card, message, Row, Col, theme } from 'antd'; import { proxyApi } from '../api/modules'; -const WS_BASE = `ws://${window.location.hostname}:8000`; +const WS_BASE = `${window.location.protocol === 'https:' ? 'wss' : 'ws'}://${window.location.host}`; export default function ProxyPage() { const { token } = theme.useToken();