只是一个关于某些 Node + Express 中间件的简单问题,该中间件在我的节点 cmd 提示符中输出 1 个对 console.log 的调用两次。它只是没有意义,想知道是否有人可以解释为什么这种情况发生在我身上。
服务器.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);
我弄清楚发生了什么,Chrome 向 favicon.ico 发出了额外的请求,因此有双输出。说得通。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)