Search code examples
node.jsimageexpressfavicon

favicon.ico 502 error while getting image from static directory


I have set the static folder to access images

app.use('/images', express.static(path.join(`assets/images`)))

and image is being stored successfully via multer and path assigned as

diskStorage({
    destination: (req, file, callback) => {
       callback(null, 'assets/images')
    }
})

but getting error

enter image description here

and I tried to skip this error by adding a route

this.app.get('/favico.ico', (req, res) => {
    res.sendStatus(204);
});

but nothing worked until now

Update

Having this problem on localhost but working fine on Heroku

I have found another reason, I run my node app on 192.168.X.X instead of localhost and got my image loaded

Now what can the problem that I am unable to get it on localhost

One more justification for that I am unable to host angular 7 app on localhost but can run on 192.168.X.X

Why is that? How to solve this?


Solution

  • Actually there was an issue in my browser configuration after resetting the browser settings and all that it got OK.

    A complete solution and discussion lies here Connection refused: localhost:4200 favicon.ico 502 in angular 7