How to set custom favicon in Express?

前端 未结 14 1916
星月不相逢
星月不相逢 2020-12-12 12:49

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 cu

14条回答
  •  盖世英雄少女心
    2020-12-12 12:54

    In app.js:

    app.use(express.static(path.join(__dirname, 'public')));
    

    Assuming the icon resides in "/public/images/favicon.ico" add next link in html's head:

    
    

    This worked fine in a project auto-generated with the command:

    express my-project
    

提交回复
热议问题