From 7a614036718538f6e790b2604f31dfb4f7160231 Mon Sep 17 00:00:00 2001 From: MatrixSeven Date: Wed, 18 Mar 2026 21:18:03 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=8A=A8=E6=80=81=E8=AE=A1=E7=AE=97WebS?= =?UTF-8?q?ocket=20URL=EF=BC=8C=E6=94=AF=E6=8C=81=E6=A0=B9=E6=8D=AE?= =?UTF-8?q?=E5=BD=93=E5=89=8D=E4=B8=BB=E6=9C=BA=E5=90=8D=E8=8E=B7=E5=8F=96?= =?UTF-8?q?=E8=BF=9E=E6=8E=A5=E5=9C=B0=E5=9D=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- chuan-next/src/lib/config.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/chuan-next/src/lib/config.ts b/chuan-next/src/lib/config.ts index 5cbc68b..999837b 100644 --- a/chuan-next/src/lib/config.ts +++ b/chuan-next/src/lib/config.ts @@ -26,7 +26,6 @@ const getCurrentBaseUrl = () => { // 动态获取 WebSocket URL - 总是在客户端运行时计算 const getCurrentWsUrl = () => { - return `ws://${window.location.hostname}:8080`; if (typeof window !== 'undefined') { // 检查是否是 Next.js 开发服务器(端口 3000 或 3001) const isNextDevServer = window.location.hostname === 'localhost' && @@ -34,7 +33,7 @@ const getCurrentWsUrl = () => { if (isNextDevServer) { // 开发模式:通过 Next.js 开发服务器访问,连接到后端 WebSocket - return 'ws://localhost:8080'; + return `ws://${window.location.hostname}:8080`; } // 生产模式或通过 Go 服务器访问:使用当前域名和端口