From dd2ea04a08e719766cc20a0709457cde25e9af9d Mon Sep 17 00:00:00 2001 From: Eric Date: Tue, 5 Mar 2024 15:13:22 +0800 Subject: [PATCH] =?UTF-8?q?:bug:websocket=E8=87=AA=E5=8A=A8=E9=80=82?= =?UTF-8?q?=E9=85=8DSSL?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/hooks/websocket.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/hooks/websocket.ts b/src/hooks/websocket.ts index 0c53fa4..5db488a 100644 --- a/src/hooks/websocket.ts +++ b/src/hooks/websocket.ts @@ -12,8 +12,8 @@ const useAdminWebSocket = () => { // ws地址 const baseUri = import.meta.env.VITE_API_URL - const host = window.location.host - const wsUri = `ws://${host}${baseUri}/ws?access_token=${accessToken}` + const protocol = window.location.protocol || '' + const wsUri = `${protocol.startsWith('https') ? 'wss' : 'ws'}://${host}${baseUri}/ws?access_token=${accessToken}` useWebSocketReturn = useWebSocket(wsUri, { autoReconnect: {