Browse Source

fix: more socketio fixes

pull/12/head
Dale 1 month ago
parent
commit
7bec2d3756
Signed by: Deiru GPG Key ID: AA250C0277B927E1
  1. 1
      docker-compose.yml
  2. 1
      next.config.js
  3. 2
      src/client/socketio/index.ts
  4. 2
      src/server/websocket/index.ts

1
docker-compose.yml

@ -39,5 +39,6 @@ services:
- miracle-backend
environment:
- NEXT_PUBLIC_MEDIA_URL=http://miracle-tv.live:1337/media
- NEXT_PUBLIC_SOCKET_PREFIX=/api
- NEXT_PUBLIC_ENV=production
- NEXT_PUBLIC_API_URL=http://miracle-tv.live:1337/api

1
next.config.js

@ -7,6 +7,7 @@ module.exports = {
// Will be available on both server and client
isDev: isDev,
apiUrl: process.env.NEXT_PUBLIC_API_URL,
socketPreix: process.env.NEXT_PUBLIC_SOCKET_PREFIX,
mediaUrl: process.env.NEXT_PUBLIC_MEDIA_URL,
},
async rewrites() {

2
src/client/socketio/index.ts

@ -10,7 +10,7 @@ export type IOClientConfig = {
export const getIOClient = (config?: IOClientConfig) => {
const socket = io(config.namespace ? config.namespace : undefined, {
transports: ["websocket"],
path: `${publicRuntimeConfig.apiUrl}/socket.io/`,
path: `${publicRuntimeConfig.socketPrefix}/socket.io/`,
});
return socket;
};

2
src/server/websocket/index.ts

@ -9,7 +9,7 @@ const onMessage = (socket: Socket) => {};
export const websocketEntry = (httpServer: http.Server) => {
const io = new SocketIO(httpServer, {
serveClient: false,
path: `${config.pathPrefix}/socket.io/`,
path: `${config.socketPrefix}/socket.io/`,
});
setupChat(io);
io.on("connection", onConnection);

Loading…
Cancel
Save