How to set custom favicon in Express

0 votes

I recently started working in Node.js and in the app.js file there is this line:

app.use(express.favicon());

Now, how do I set up my own custom favicon.ico?

Jul 17, 2020 in Node-js by kartik
• 37,510 points
5,013 views

1 answer to this question.

0 votes

Hello @kartik,

 Just use:

app.use('/favicon.ico', express.static('images/favicon.ico'));

OR

In express:

 //you probably have something like this already    
app.use("/public", express.static('public')); 

Then put your favicon in public and add the following line in your html's head:

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

Hope it works!!

Thank You!!

answered Jul 17, 2020 by Niroj
• 82,880 points

Related Questions In Node-js

0 votes
1 answer

How to Pass route control with optional parameter after root in express?

Hello @kartik, That would work depending on what ...READ MORE

answered Oct 12, 2020 in Node-js by Niroj
• 82,880 points
13,326 views
0 votes
1 answer

How to setup route for websocket server in express?

Hello @kartik, You'll want to use the path option: var wss ...READ MORE

answered Oct 16, 2020 in Node-js by Niroj
• 82,880 points
5,021 views
0 votes
1 answer

How to use the middleware to check the authorization before entering each route in express?

Hello @kartik, As long as app.use(authChecker); is before app.use(app.router); it will get ...READ MORE

answered Nov 30, 2020 in Node-js by Niroj
• 82,880 points
1,665 views
0 votes
1 answer

How to set different destinations in nodejs using multer?

With multer 1.2.1. You need to use DiskStorage to specify where & how of the ...READ MORE

answered Jun 13, 2022 in Node-js by Neha
• 9,060 points
4,868 views
0 votes
1 answer

jQuery AJAX fires error callback on window unload - how do I filter out unload and only catch real errors?

Hello, In the error callback or $.ajax you have three ...READ MORE

answered Apr 27, 2020 in Java-Script by Niroj
• 82,880 points
3,714 views
0 votes
1 answer

How do I pass command line arguments to a Node.js program?

Hello @kartik, If your script is called myScript.js ...READ MORE

answered May 5, 2020 in Java-Script by Niroj
• 82,880 points
2,922 views
0 votes
1 answer

Error:Issue when trying to use IN() in wordpress database

Hello @kartik, Try this code : // Create an ...READ MORE

answered May 8, 2020 in PHP by Niroj
• 82,880 points
832 views
+2 votes
1 answer

How do I debug Node.js applications?

Hello @kartik, Use node-inspector  from any browser supporting WebSocket. Breakpoints, ...READ MORE

answered Jul 8, 2020 in Node-js by Niroj
• 82,880 points
772 views
0 votes
1 answer

How to get GET (query string) variables in Express.js on Node.js?

Hello @kartik, Since you've mentioned Express.js in your ...READ MORE

answered Jul 8, 2020 in Node-js by Niroj
• 82,880 points
3,001 views
0 votes
1 answer

How to include route handlers in multiple files in Express?

Hello @kartik, If you want to put the routes ...READ MORE

answered Jul 15, 2020 in Node-js by Niroj
• 82,880 points
5,526 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP