Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Favicon not showing locally on express

Am I missing something? Here is what I have:

var express = require('express');
var favicon = require('serve-favicon');
var path = require('path');

var app = express();

app.use(favicon(path.join(__dirname, 'public', 'favicon.ico'))); 

app.use('/api', require('./routes/api'));

app.listen(3000);

My favicon is located as specified in the public folder and the same name. I have some other routes setup separately in a file. The favicon doesn't appear to be working, I must be missing something.

like image 536
Babagana Zannah Avatar asked Nov 30 '22 09:11

Babagana Zannah


1 Answers

The browser might have cached an older favicon. You can force the browser to refresh the cache by adding a version to the new favicon like so:

<link rel="icon" href="favicon.ico?v=1.1">
like image 175
moeabdol Avatar answered Dec 13 '22 15:12

moeabdol