diff --git a/src/App.js b/src/App.js index 1c74677..805876a 100644 --- a/src/App.js +++ b/src/App.js @@ -29,14 +29,14 @@ import UcOffer from './pages/offer/UcOffer'; function App() { const dispatch = useDispatch(); const { pathname } = useLocation(); - const token = useSelector((state) => state.auth.token); + const token = localStorage.getItem('token'); useEffect(() => { const storedToken = localStorage.getItem('token'); if (storedToken) { dispatch(checkLogIn()); } - }, [dispatch]); + }, [dispatch, token]); useEffect(() => { window.scrollTo(0, 0); diff --git a/src/pages/chat/Chat.js b/src/pages/chat/Chat.js index 415262e..fe30b73 100644 --- a/src/pages/chat/Chat.js +++ b/src/pages/chat/Chat.js @@ -22,8 +22,9 @@ const Chat = () => { useEffect(() => { if (token) { const newSocket = io('https://cyberswap.uz', { + path: '/api/socket.io', query: { token: encodeURIComponent(token) }, - transports: ['websocket'], // use WebSocket first, fallback to polling if necessary + transports: ['websocket'], }); setSocket(newSocket);