I'm getting into the backend with Node and express , I wanted to create a middleware that show on the console that the route was not found if you try to do a request to a route that does not exist , so I did this way
server.get('/' , (req,res) => {
res.render('index.html')
})
server.use((req,res,next) => {
console.log('NOT FOUND')
})
If i'm not wrong , this middleware should just execute if I do the request to a route that is not / since it is the only that exist , and when I try in postman it have exactly the behavior that it should , but when I try on the browser it execute the middleware even if the request is to / and my view is render and sometimes it even execute it two times and it show NOT FOUND two times on the console
I don't know why Postman and the Browser are doing different things , Am I doing something wrong?
Thanks for the help
There is not a lot of information here, but my best guess would be that maybe index.html references som other resources (js,css, favicon, ++) that it tries to load, but it does not find. Whereas postman does not try to load these resources?
Update: as per OPs comment, to "disable" favicons, have a look at this post: How to prevent favicon.ico requests?