nodejs - http.createServer seems to call twice
Generally, favicon.ico
is fetched by the browsers. So, the two calls.
Solution to this issue can be checking for request URL if it's fetching favicon.ico
or not.
http.createServer(function (req, res) {
if (req.url != '/favicon.ico') {
// do your stuffs
}
}).listen(3500);
That is normal - your browser makes more than one call.
Most browsers make a call to grab /favicon.ico
for example.
Try to log the url:
console.log(req.url);
and you'll see what's being called.