app.use(function(req,res,next){ console.log('middleware executed'); next(); });
app.get('/1',function(req,res){ console.log('/1'); res.end(); });
app.get('/2',function(req,res){ console.log('/2'); res.end(); });
...
It works. Middleware executed on both /1 and /2 requests.
Now I want middleware to not be executed on request page /1, but on all pages below:
app.get('/1',function(req,res){ console.log('/1'); res.end(); });
app.use(function(req,res,next){ console.log('middleware executed'); next(); });
app.get('/2',function(req,res){ console.log('/2'); res.end(); });
...
In this case middleware won't execute. Even on request page /2. What's wrong? How to solve this?