From e7edb561073e067e50b965aa305e6fb58f6adc1f Mon Sep 17 00:00:00 2001 From: yml2213 Date: Mon, 22 Jun 2026 20:12:46 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8DHTTPS=E7=8E=AF=E5=A2=83?= =?UTF-8?q?=E4=B8=8BWebSocket=E8=BF=9E=E6=8E=A5=E8=A2=AB=E6=8B=A6=E6=88=AA?= =?UTF-8?q?=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - WebSocket URL 根据页面协议自动选择 ws/wss - 使用 window.location.host 替代硬编码端口,适配内网穿透代理场景 Co-Authored-By: Claude Fable 5 --- web/frontend/src/pages/LoginTasksPage.tsx | 2 +- web/frontend/src/pages/ProxyPage.tsx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) 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();