Gathering detailed insights and metrics for serve-favicon
Gathering detailed insights and metrics for serve-favicon
Gathering detailed insights and metrics for serve-favicon
Gathering detailed insights and metrics for serve-favicon
npm install serve-favicon
Typescript
Module System
Min. Node Version
Node Version
NPM Version
JavaScript (100%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
MIT License
623 Stars
231 Commits
75 Forks
19 Watchers
8 Branches
30 Contributors
Updated on Jul 10, 2025
Latest Version
2.5.1
Package Id
serve-favicon@2.5.1
Unpacked Size
14.67 kB
Size
5.76 kB
File Count
5
NPM Version
10.9.0
Node Version
22.10.0
Published on
Jun 10, 2025
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
Node.js middleware for serving a favicon.
A favicon is a visual cue that client software, like browsers, use to identify a site. For an example and more information, please visit the Wikipedia article on favicons.
Why use this module?
favicon.ico
frequently and indiscriminately, so you
may wish to exclude these requests from your logs by using this middleware
before your logger middleware.ETag
based on the contents of the icon, rather
than file system properties.Content-Type
.Note This module is exclusively for serving the "default, implicit favicon",
which is GET /favicon.ico
. For additional vendor-specific icons that require
HTML markup, additional middleware is required to serve the relevant files, for
example serve-static.
This is a Node.js module available through the
npm registry. Installation is done using the
npm install
command:
1$ npm install serve-favicon
Create new middleware to serve a favicon from the given path
to a favicon file.
path
may also be a Buffer
of the icon to serve.
Serve favicon accepts these properties in the options object.
The cache-control
max-age
directive in ms
, defaulting to 1 year. This can
also be a string accepted by the ms
module.
Typically this middleware will come very early in your stack (maybe even first)
to avoid processing any other middleware if we already know the request is for
/favicon.ico
.
1var express = require('express') 2var favicon = require('serve-favicon') 3var path = require('path') 4 5var app = express() 6app.use(favicon(path.join(__dirname, 'public', 'favicon.ico'))) 7 8// Add your routes here, etc. 9 10app.listen(3000)
1var connect = require('connect') 2var favicon = require('serve-favicon') 3var path = require('path') 4 5var app = connect() 6app.use(favicon(path.join(__dirname, 'public', 'favicon.ico'))) 7 8// Add your middleware here, etc. 9 10app.listen(3000)
This middleware can be used anywhere, even outside express/connect. It takes
req
, res
, and callback
.
1var http = require('http') 2var favicon = require('serve-favicon') 3var finalhandler = require('finalhandler') 4var path = require('path') 5 6var _favicon = favicon(path.join(__dirname, 'public', 'favicon.ico')) 7 8var server = http.createServer(function onRequest (req, res) { 9 var done = finalhandler(req, res) 10 11 _favicon(req, res, function onNext (err) { 12 if (err) return done(err) 13 14 // continue to process the request here, etc. 15 16 res.statusCode = 404 17 res.end('oops') 18 }) 19}) 20 21server.listen(3000)
No vulnerabilities found.
Reason
21 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 10
Reason
no binaries found in the repo
Reason
no dangerous workflow patterns detected
Reason
update tool detected
Details
Reason
GitHub workflow tokens follow principle of least privilege
Details
Reason
0 existing vulnerabilities detected
Reason
license file detected
Details
Reason
security policy file detected
Details
Reason
project has 21 contributing companies or organizations
Details
Reason
SAST tool detected but not run on all commits
Details
Reason
19 out of 23 merged PRs checked by a CI test -- score normalized to 8
Reason
dependency not pinned by hash detected -- score normalized to 7
Details
Reason
Found 9/20 approved changesets -- score normalized to 4
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
branch protection not enabled on development/release branches
Details
Reason
project is not fuzzed
Details
Score
Last Scanned on 2025-07-07T21:23:56Z
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More