node.js - Allow websocket connection only from one URL -


my websocket application accepting connections this:

wsserver.on('request', function(request) {     console.log(request);     if(request.origin == "https://www.my-domain.com"){          var connection  =   request.accept(null, request.origin);           /* lines of code             ...          */      } else {         //here want block request     } 

is here function .decline()? or .notaccept() or...? when trying connect websocket different url, status "pending" long time. enter image description here

it's shown here:

wsserver.on('request', function(request) {   if (! originisallowed(request.origin)) {     // make sure accept requests allowed origin      request.reject();     console.log((new date()) + ' connection origin ' + request.origin + ' rejected.');     return;   }   ... }); 

you'd have replace originisallowed(request.origin) own check.


Comments