diff --git a/packages/backend/src/helpers.js b/packages/backend/src/helpers.js index 06cabf75..d102309e 100644 --- a/packages/backend/src/helpers.js +++ b/packages/backend/src/helpers.js @@ -1146,8 +1146,8 @@ async function jwt_auth(req){ else if(req.query && req.query.auth_token) token = req.query.auth_token; // Socket - else if(req.handshake && req.handshake.query && req.handshake.query.auth_token) - token = req.handshake.query.auth_token; + else if(req.handshake && req.handshake.auth && req.handshake.auth.auth_token) + token = req.handshake.auth.auth_token; if(!token || token === 'null') throw('No auth token found'); diff --git a/packages/backend/src/services/WebServerService.js b/packages/backend/src/services/WebServerService.js index 73d95bb9..cecbd3ea 100644 --- a/packages/backend/src/services/WebServerService.js +++ b/packages/backend/src/services/WebServerService.js @@ -158,7 +158,7 @@ class WebServerService extends BaseService { // Socket.io middleware for authentication socketio.use(async (socket, next) => { - if (socket.handshake.query.auth_token) { + if (socket.handshake.auth.auth_token) { try { let auth_res = await jwt_auth(socket); // successful auth @@ -168,7 +168,7 @@ class WebServerService extends BaseService { socket.join(socket.user.id); next(); } catch (e) { - console.log('socket auth err'); + console.log('socket auth err', e); } } }); diff --git a/packages/puter-js/src/modules/FileSystem/index.js b/packages/puter-js/src/modules/FileSystem/index.js index a5540102..0e6b2679 100644 --- a/packages/puter-js/src/modules/FileSystem/index.js +++ b/packages/puter-js/src/modules/FileSystem/index.js @@ -65,7 +65,7 @@ class FileSystem{ } this.socket = io(this.APIOrigin, { - query: { + auth: { auth_token: this.authToken, } }); diff --git a/src/UI/UIDesktop.js b/src/UI/UIDesktop.js index c6715b29..e6638153 100644 --- a/src/UI/UIDesktop.js +++ b/src/UI/UIDesktop.js @@ -43,7 +43,7 @@ async function UIDesktop(options){ // connect socket. window.socket = io(window.gui_origin + '/', { - query: { + auth: { auth_token: window.auth_token } });