From f514a97df6911bf519b34dd353719e75b5de6a59 Mon Sep 17 00:00:00 2001 From: Howard Chung Date: Fri, 7 Feb 2025 07:50:21 +0000 Subject: [PATCH] fix for url encoding issue? --- server/server.ts | 13 +++++++++---- src/components/App/App.tsx | 2 +- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/server/server.ts b/server/server.ts index 9bd64f613..2b79c95f5 100644 --- a/server/server.ts +++ b/server/server.ts @@ -60,13 +60,14 @@ if (config.SSL_KEY_FILE && config.SSL_CRT_FILE) { } const io = new Server(server, { cors: {}, transports: ['websocket'] }); io.engine.use(async (req: any, res: Response, next: () => void) => { - const key = req._query.roomId; - if (!key) { + const roomId = req._query.roomId; + if (!roomId) { return next(); } // Attempt to ensure the room being connected to is loaded in memory // If it doesn't exist, we may fail later with "invalid namespace" - const shard = resolveShard(key.slice(1)); + const shard = resolveShard(roomId); + const key = '/' + roomId; // Check to make sure this shard should load this room const isCorrectShard = !config.SHARD || shard === config.SHARD; if (isCorrectShard && postgres && !rooms.has(key)) { @@ -82,7 +83,11 @@ io.engine.use(async (req: any, res: Response, next: () => void) => { if (data) { const room = new Room(io, key, data); rooms.set(key, room); - console.log('loading room %s into memory on shard %s', key, config.SHARD); + console.log( + 'loading room %s into memory on shard %s', + roomId, + config.SHARD, + ); } } next(); diff --git a/src/components/App/App.tsx b/src/components/App/App.tsx index a0b144a67..67c809268 100644 --- a/src/components/App/App.tsx +++ b/src/components/App/App.tsx @@ -340,7 +340,7 @@ export default class App extends React.Component { uid: this.context.user?.uid, token: await this.context.user?.getIdToken(), shard, - roomId, + roomId: roomId.slice(1), }, }); this.socket = socket;