Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Favicon requested on every route change

Tags:

react-router

Favicon requested on every route change

I think it's strange that a route change would trigger a request for the favicon.

Is this intended or what is going on here?

like image 607
user1655758 Avatar asked Feb 15 '16 12:02

user1655758


3 Answers

I had the same problem and I believe the problem started with the Chrome 49.0.2623.87. I hope it is going to be fixed in the coming updates. For now, I am using the script below, which can be found here.

var favIcon = "favicon.ico"; var docHead = document.getElementsByTagName('head')[0];        var newLink = document.createElement('link'); newLink.rel = 'shortcut icon'; newLink.href = 'data:image/png;base64,'+favIcon; docHead.appendChild(newLink); 

It will not stop the favicon requests, so for a short period of time you still will see the default favicon from chrome, but I believe there is not much to be done about that.

like image 131
Jeferson Pagel Avatar answered Oct 11 '22 19:10

Jeferson Pagel


I found a solution on Github. Quoting @Doeke:

Try reordering the favicon link tags. For me, putting the 16x16 link before 32x32 fixed this issue. As for why this works... I have no idea.

For me, it meant putting the only favicon <link> on my page right at the top of <head>, after <meta charset>.

like image 38
John Freeman Avatar answered Oct 11 '22 20:10

John Freeman


Try to serve favicon.ico from your server or add route for that. I was experienced such error when using express catch-all app.get('*') method which redirected all requests to index.html (even for favicon)

like image 33
p0rsche Avatar answered Oct 11 '22 20:10

p0rsche