Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Node Express Middleware outputting console.log() twice from one call?

just a quick question about some Node + Express middleware that is outputting 1 call to console.log twice in my node cmd prompt. It just doesn't make sense and was wondering if someone could explain why this is occurring for me.

server.js

var express = require('express');
var app = express();

//Outputs in my console twice?!
app.use('/', function(req, res, next) {
    console.log('Request Logged by Node+Express Server Middleware @ ' + Date());
    next();
});

app.get('*', function(req, res) {
    res.send('Hey world.');
});

app.listen(1337);
like image 519
JohnWick Avatar asked Oct 14 '25 20:10

JohnWick


1 Answers

I figured out what was going on, Chrome was making an additional request to favicon.ico, thus the double outputs. Makes sense.

like image 57
JohnWick Avatar answered Oct 17 '25 10:10

JohnWick