1 var HTTP = require ("HTTP"); 2 var Server = http. createserver (); 3 server. on ("request", function (req, Res) {5 console. log (req. URL); 6 res. end (); 7}); 8 server. listen (1337, "127.0.0.1 ");
Such code will have two requests during the request:
In the first example, the URL address is the target URL of the client request entered by the user. "/" indicates that the target URL address is the root directory of the Web application.
The second target URL address is the display icon of the page in the favorites folder. The default value is favicon. ico. The target URL address of the automatically sent request.
You can modify the preceding code to block such requests.
1 var HTTP = require ("HTTP"); 2 var Server = http. createserver (); 3 server. on ("request", function (req, Res) {4 If (req. URL! = "/Favicon. ICO ") 5 console. log (req. URL); 6 res. end (); 7}); 8 server. listen (1337, "127.0.0.1 ");
Node favicon. Icon request