change router matching "admin*" to "admin" & "admin/*" (#9128)

This commit is contained in:
Pierre Noël 2021-01-18 09:54:41 +01:00 committed by GitHub
parent 82380da065
commit 23d41fd18d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -81,16 +81,18 @@ module.exports = strapi => {
if (!strapi.config.serveAdminPanel) return;
const buildDir = path.resolve(strapi.dir, 'build');
const serveAdmin = ctx => {
ctx.type = 'html';
ctx.body = fs.createReadStream(path.join(buildDir + '/index.html'));
};
strapi.router.get(
`${strapi.config.admin.path}/*`,
serveStatic(buildDir, { maxage: maxAge, defer: false, index: 'index.html' })
);
strapi.router.get(`${strapi.config.admin.path}*`, ctx => {
ctx.type = 'html';
ctx.body = fs.createReadStream(path.join(buildDir + '/index.html'));
});
strapi.router.get(`${strapi.config.admin.path}`, serveAdmin);
strapi.router.get(`${strapi.config.admin.path}/*`, serveAdmin);
},
};
};