Authenticating socket io connections using JWT
It doesn’t matter if the token was created on another server. You can still verify it if you have the right secret key and algorithm. Implementation with jsonwebtoken module client const {token} = sessionStorage; const socket = io.connect(‘http://localhost:3000’, { query: {token} }); Server const io = require(‘socket.io’)(); const jwt = require(‘jsonwebtoken’); io.use(function(socket, next){ if (socket.handshake.query … Read more