mirror of
https://github.com/strapi/strapi.git
synced 2025-09-25 16:29:34 +00:00
Fix: Make favicon middleware backwards compatible with pngs
This commit is contained in:
parent
527b7852a5
commit
b6ee5a9d1c
@ -1,5 +1,6 @@
|
||||
'use strict';
|
||||
|
||||
const { existsSync } = require('fs');
|
||||
const { resolve } = require('path');
|
||||
const { defaultsDeep } = require('lodash/fp');
|
||||
const favicon = require('koa-favicon');
|
||||
@ -13,7 +14,19 @@ const defaults = {
|
||||
* @type {import('./').MiddlewareFactory}
|
||||
*/
|
||||
module.exports = (config, { strapi }) => {
|
||||
const { maxAge, path: faviconPath } = defaultsDeep(defaults, config);
|
||||
const { maxAge, path: faviconDefaultPath } = defaultsDeep(defaults, config);
|
||||
const { root: appRoot } = strapi.dirs.app;
|
||||
let faviconPath = faviconDefaultPath;
|
||||
|
||||
return favicon(resolve(strapi.dirs.app.root, faviconPath), { maxAge });
|
||||
/** TODO (v5): Updating the favicon to use a png caused
|
||||
* https://github.com/strapi/strapi/issues/14693
|
||||
*
|
||||
* This check ensures backwards compatibility until
|
||||
* the next major version
|
||||
*/
|
||||
if (!existsSync(resolve(appRoot, faviconPath))) {
|
||||
faviconPath = 'favicon.ico';
|
||||
}
|
||||
|
||||
return favicon(resolve(appRoot, faviconPath), { maxAge });
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user