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, and only people from 124.124.124.124 can access my server's /
route.
I know that express-ipfilter can restrict site access by IP Address. But it cannot apply the filter to specific routes.
I also know that adding app.use(ipfilter(ips, {}));
in the middle of the routes can apply filter only to the routes below:
var express = require('express'),
ipfilter = require('express-ipfilter').IpFilter;
var ips = ['::ffff:127.0.0.1'];
var app = express();
app.get('/test', function(req, res) {
res.send('test');
});
app.use(ipfilter(ips, {})); // the ipfilter only applies to the routes below
app.get('/', function(req, res) {
res.send('Hello World');
});
app.listen(3000);
But I want different filters for different routes.
Is it possible to do this?