balderdashy / sails.io.js

Browser SDK for communicating w/ Sails via sockets
https://sailsjs.com/documentation/reference/web-sockets/socket-client
183 stars 118 forks source link

io.socket.get 401 code for room connection #130

Open DmitrKulagin opened 1 year ago

DmitrKulagin commented 1 year ago

Hey! My old project used io.socket.get to connect to secret rooms.

io.socket.get('/list/handshake', function (data, jwr) { if (jwr.error) { return; } });

io.socket.get('/terminal/handshake', function (data, jwr) { if (jwr.error) { return; } });

After auditing the packages, I received updates and am now getting a 401 error when trying to connect.

I'm assuming that it's necessary to pass cookie bitches and the io.socket.request method is more suitable for this, but I have a poor idea of what exactly the sails require to pass the request authorization. Who faced a similar problem and what solution can work?

io.socket.request({ method: 'get', url: '/list/handshake', headers: { // cookie: document.cookie, 'x-csrf-token': window.SAILS_LOCALS._csrf ? window.SAILS_LOCALS._csrf : '', } }, function (data, jwr) { if (jwr.error) { return; } });

io.socket.request({ method: 'get', url: '/terminal/handshake', }, function (data, jwr) { if (jwr.error) { return; } });

SundaramMaheshkumar commented 11 months ago

Check whether this is of any help. Thanks