Reputation: 856
I'm currently diving into node.js stuff starting with very simple examples.
The following code is not really a big deal but already confuses me:
require('http')
.createServer( function( req, res ) {
console.log( 'receiving request' );
res.end( 'end' );
} )
.listen( 1337, "localhost" );
After having started the server via console I called http://localhost:1337 In the console I got the "receiving request"-message two times not one time as expected.
What is this all about? Did I already mess this easy thin up?
Upvotes: 2
Views: 144
Reputation: 13630
Browsers will automatically make a call to /favicon.ico when requesting a page. Your node server responds to both the "page" request and the "favicon.ico" request. Hence the two log lines.
Upvotes: 7