A rewrite of serve-favicon module.
Node.js middleware to serve favicon.ico
file.
pnpm i @tinyhttp/favicon
import { favicon } from '@tinyhttp/favicon'
favicon
accepts these properties in the options object.
Path to icon, required. Passed as the first argument.
Sets Cache-Control: maxAge=
header, optional. Default is one year. Passed with object in the second argument.
import { favicon } from '@tinyhttp/favicon'
import { createServer } from 'node:http'
import path from 'node:path'
createServer(favicon(path.join(process.cwd(), 'public', 'favicon.ico')).listen(3000)