从 node.js 提供 favicon.ico

li-*_*raz 3 node.js express

我已经使用express构建了一个小型节点服务器,我想提供包含角度应用程序的index.html。浏览器如何发送对 favicon.ico 的 GET 请求。我已经安装了serve-favicon,但它仍然寻找物理文件。有没有办法覆盖它?或者从哪里可以找到这样的文件

Rya*_*yan 5

推荐的方法实际上只是在你的index.html中使用链接标签:

<link rel="icon" href="/img/favicon.png">
Run Code Online (Sandbox Code Playgroud)

只需更改 href 以链接到公共文件夹中的 img 即可。

http://www.w3.org/2005/10/howto-favicon