0

I'm having an issue getting my favicon.ico to display on my local node.js/Express server.

What I've done:

I have installed the serve-favicon package as described here.

My main app.js file contains:

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

const app = express();
app.use(favicon(path.join(__dirname,'public','img','favicon','favicon.ico')));

Within my layout html file, I have included the following tag in the section:

<link rel="shortcut icon" href="/public/img/favicon/favicon.ico">

When I open my local website, the favicon is the default globe/blank. No resource is mounted. Navigating to "localhost:port/favicon.ico" WILL load the desired favicon and and mount it correctly, but ONLY on that page. Navigating to any other page will cause the favicon to disappear. Refreshing and closing/reopening the browser as described here does not do anything.

Accessing my local server from different browsers (i.e. Mozilla, Edge) has no effect and the favicon will not load. The only way for me to see that the favicon is properly sized/formatted/path'd is to access "localhost:port/favicon.ico"

Deleting my browser cache or renaming the favicon to something else (i.e. favicon1.ico) does not fix the issue.

How can I rectify this? Any advice/assistance would be greatly appreciated. Thanks for your time!

zwatts
  • 1
  • 1

0 Answers0