Skip to content

Commit

Permalink
🐛websocket自动适配SSL
Browse files Browse the repository at this point in the history
  • Loading branch information
evil0th authored and Hccake committed Mar 5, 2024
1 parent 33185e1 commit dd2ea04
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/hooks/websocket.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down

0 comments on commit dd2ea04

Please sign in to comment.