从 egg 项目配置里找到这一段代码:
https://github.com/eggjs/egg/blob/master/config/config.default.js#L205C21-L205C74
/** * The option of `siteFile` middleware * * You can map some files using this options, it will response immdiately when matching. * * @member {Object} Config#siteFile - key is path, and value is url or buffer. * @property {String} cacheControl - files cache , default is public, max-age=2592000 * @example * // specific app's favicon, => '/favicon.ico': 'https://eggjs.org/favicon.ico', * config.siteFile = { * '/favicon.ico': 'https://eggjs.org/favicon.ico', * }; */ config.siteFile = { '/favicon.ico': fs.readFileSync(path.join(__dirname, 'favicon.png')), // default cache in 30 days cacheControl: 'public, max-age=2592000', };
然后在自己项目的 config.default.js 里照着加上就行,注意头部引入了 fs 和 path 这两个库。
Other: HTTP安全报头检测
Link:https://www.cnblogs.com/farwish/p/17726267.html
标签:ico,自定义,FAQ,favicon,eggjs,https,siteFile,config From: https://www.cnblogs.com/farwish/p/17726267.html