Skip to content

Commit

Permalink
feat: Socker.IO get token add error handler
Browse files Browse the repository at this point in the history
  • Loading branch information
allyusd committed Sep 17, 2023
1 parent 0440f9e commit 4ab478f
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion pages/api/mock/socketio.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,11 @@ const socketio = async (req: NextApiRequest, res: NextApiResponseServerIO) => {

io.use((socket, next) => {
const token = socket.handshake.auth.token;
next();
if (token == undefined) {
next(new Error("not authorized"));
} else {
next();
}
});

io.on(SOCKET_EVENT.CONNECT, (socket) => {
Expand Down

0 comments on commit 4ab478f

Please sign in to comment.