据我所知,chrome中出现重复请求的原因是在第一个请求中获取/favicon.ico,在第二个请求中获取URI。但正如您在我的简单测试代码中看到的那样,两个请求都访问了完全相同的 URL,而不是从第一个请求中获取 /favicon.ico。这给我的项目带来了意想不到的结果。
快递代码
app.get('/test',(req,res)=>{
console.log(`URL : ${req.originalUrl}`);
if(req.url=='/test'){
res.writeHead(200);
res.end();
}else{
res.writeHead(404);
res.end();
}
})
结果
URL : /test
GET /test 200 - - 1.761 ms
URL : /test
GET /test 200 - - 0.612 ms