1

I have a simple HTTP server

require('http').createServer(function(req, res) {
    res.writeHead(200, {'Content-Type': 'text/plain'});
    res.end('Hello World!');

    console.log('Got a request');   
}).listen(4000);

However, when I run it 'Got a request' is written 3 times in the console. Any idea why?

1
  • Check the network tab in your browsers console, you should see every request between the client and the server. Like Sachacr said one would be favicon Commented Jun 3, 2015 at 14:21

1 Answer 1

2

It's maybe your browser who try to get your favicon

You can confirm this by using : console.log('Got a request : ' + req.url);

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks - that was it indeed (apologies for the late reply).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.