Can someone tell me what is going on? I have an aplication:
var express = require('express')
, http = require('http')
, app = express()
, port = 3000
, mw = require('./lib/middlewareView')
app.use(mw());
app.get('/', function (req, res, next) {
res.send("hello");
});
app.listen(port, function() {
console.log("Listening on " + port);
});
and /lib/middlewareView.js :
module.exports = function middlewareView(){
return function middlewareView(req, res, next) {
console.log("middleware run");
next();
};
};
When I'm using port 3000 and open http://localhost:3000/ everything seems to be fine.
console output:
Listening on 3000
middleware run
hello
But if I switch to port 5000, console prints this:
Listening on 5000
middleware run
hello
middleware run
middleware run
So the middleware runs 3 times during one request, right? Is it normal?
Its probably to do with favicon.ico - this happens when retrieving the icon for your site, check logs to make sure...