您好,遵循简单直接的教程。一切正常,但我只是好奇为什么当我刷新/访问我的页面时,我得到一个双request received
?
function onRequest(request, response){
console.log('request received');
response.writeHead(200, {"Content-Type": "text/plain"});
response.write('Hello world baby');
response.end();
}
//creating server
http.createServer(onRequest).listen(8888);
console.log("server has started");
答案 0 :(得分:2)
您的浏览器正在寻找favicon.ico
,然后它会发送实际内容请求。尝试console.log
请求和响应以获取更多信息。