How to set custom favicon in Express?

前端 未结 14 1894
星月不相逢
星月不相逢 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 13:00

    You must install middleware to serve the favicon.

    I tried this just now:

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

    and got this error message back:

    Error: Most middleware (like favicon) is no longer bundled with Express and must be installed separately. Please see https://github.com/senchalabs/connect#middleware.

    I think we can take that as being definitive.

提交回复
热议问题