How to write an express route middleware that will only catch actions?

I'm using the following middleware :

  app.use(function(req,res,next){
     console.log(req.url)
     next()
  });

but it catches every request, including images/css/js etc...

If I just want to catch the actions, what should I do?

You could put your "static handler" middleware before this one, if the request matches the static middleware route, it should not reach your middleware at all.

So try:

app.use(express.static(__dirname + '/public'));
app.use(function(req,res,next){
  console.log(req.url)
  next()
});

detail explanation about express and connect middleware Check this url http://www.hacksparrow.com/how-to-write-midddleware-for-connect-express-js.html