Is it possible to apply different ip filters to different routes?
For example, I want only people from 123.123.123.123 can access my server\'s /test
route,
Yeah, it's possible. You could do something like:
app.get('/test', function(req, res){
var trustedIps = ['123.123.123.123'];
var requestIP = req.connection.remoteAddress;
if(trustedIps.indexOf(requestIP) >= 0) {
// do stuff
} else {
// handle unallowed ip
}
})
You may need to make sure that requestIP
is correctly formatted though.