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.
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">
This answers your question.
It says:
Check what is in the <head> section of the document. While a browser may implement a default favicon.ico behavior, it can also be controlled from the <head> section by either telling the browser what file/path you want it to fetch the favicon from, what type of file it is or that you don't want it to look for a favicon at all.
Here are two other references on the topic that cover some of the specifics: