fix: fixed websockets

This commit is contained in:
Lukian 2025-04-09 11:49:26 +02:00
parent edc6f34733
commit 1fee32f1d2
5 changed files with 14 additions and 53 deletions

View file

@ -10,16 +10,21 @@ import Register from './pages/Register'
import CreateChannel from './pages/CreateChannel'
import ChannelsPage from './pages/ChannelsPage'
const socket = new WebSocket("/api/ws");
setInterval(() => {
socket.send("ping");
}, 30 * 1000);
createRoot(document.getElementById('root')!).render(
<BrowserRouter>
<Routes>
<Route path="/" element={<Home />} />
<Route path="/c/:name" element={<ChannelPage />} />
<Route path="/u/:username" element={<UserPage />} />
<Route path="/" element={<Home socket={socket} />} />
<Route path="/c/:name" element={<ChannelPage socket={socket} />} />
<Route path="/u/:username" element={<UserPage socket={socket} />} />
<Route path="/login" element={<Login />} />
<Route path="/register" element={<Register />} />
<Route path="/create-channel" element={<CreateChannel />} />
<Route path="/channels" element={<ChannelsPage />} />
<Route path="/channels" element={<ChannelsPage socket={socket} />} />
</Routes>
</BrowserRouter>
)