File tree Expand file tree Collapse file tree 2 files changed +7
-7
lines changed Expand file tree Collapse file tree 2 files changed +7
-7
lines changed Original file line number Diff line number Diff line change @@ -4,8 +4,6 @@ import useWebSocket from 'react-use-websocket'
44import useDebouncedFunction from "./useDebouncedFunction.hook"
55import { useHttp } from "./http.hook"
66
7- const WS_PORT = process . env . WS_PORT || 3030
8-
97/**
108 * Хук веб-сокета обновления данных
119 * @param {void } updateData
@@ -20,10 +18,9 @@ function useUpdaterSocket(updateData, auth) {
2018 /**колбек для получения url сокета */
2119 const getSocketUrl = useCallback ( async ( ) => {
2220 return new Promise ( resolve => {
23- request ( "/getIp " )
21+ request ( "/getSocketAddress " )
2422 . then ( ( data ) => {
25- const ip = data . ip
26- const socketAddress = "ws://" + ( ip || "localhost" ) + ":" + WS_PORT
23+ const socketAddress = data . socketAddress
2724 console . log ( "socketAddress" , socketAddress )
2825 resolve ( socketAddress )
2926 } )
Original file line number Diff line number Diff line change @@ -22,9 +22,12 @@ const app = express()
2222
2323app . use ( express . json ( { extended : true } ) )
2424
25- app . get ( '/getIp ' , ( req , res ) => {
25+ app . get ( '/getSocketAddress ' , ( req , res ) => {
2626 getIp ( )
27- . then ( ( ip ) => res . status ( 200 ) . json ( { ip } ) )
27+ . then ( ( ip ) => {
28+ const socketAddress = ( httpsRedirect ? "wss" : "ws" ) + "://" + ( ip || "localhost" ) + ":" + WS_PORT
29+ res . status ( 200 ) . json ( { socketAddress } )
30+ } )
2831 . catch ( ( ) => res . status ( 500 ) )
2932} )
3033
You can’t perform that action at this time.
0 commit comments