Thursday, 10 May 2018

Anyway to prevent other clients from accessing Node.js WebSocket? (WS Module)

Hello all, I am just wondering if there is a way to ensure no other client/domain can access my websocket running on a Node.js instance. I am using the WS Module found on NPM.Server Code: var WebSocketServer = require('ws').Server wss = new WebSocketServer({port: 8000}) wss.on('connection', function (ws) { })Client Code: var wss = new WebSocket('wss://mydomain.com'); wss.onmessage = function(e) { var data = JSON.parse(e.data); }I would like for only users on my website (mydomain.com) to access my websocket feed. Any help would be greatly appreciated! Thank you!

Submitted May 10, 2018 at 07:40PM by TCTC21

No comments:

Post a Comment