fix(core.gbapp): /logs working again.

This commit is contained in:
rodrigorodriguez 2023-03-27 10:07:28 -03:00
parent 0c443618a6
commit d08e11fef4

View file

@ -212,24 +212,6 @@ export class GBServer {
await minService.buildMin(instances); await minService.buildMin(instances);
if (process.env.ENABLE_WEBLOG) { if (process.env.ENABLE_WEBLOG) {
const admins = {
admin: { password: process.env.ADMIN_PASS }
};
// ... some not authenticated middlewares
server.use(async (req, res, next) => {
if (req.originalUrl.startsWith('/logs')) {
const user = auth(req);
if (!user || !admins[user.name] || admins[user.name].password !== user.pass) {
res.set('WWW-Authenticate', 'Basic realm="example"');
return res.status(401).send();
}
} else {
return next();
}
});
// If global log enabled, reorders transports adding web logging. // If global log enabled, reorders transports adding web logging.
const loggers = GBLog.getLogger(); const loggers = GBLog.getLogger();
@ -237,7 +219,24 @@ export class GBServer {
} }
server.get('*', async (req, res, next) => { server.get('*', async (req, res, next) => {
await GBSSR.ssrFilter(req, res, next); if (req.originalUrl.startsWith('/logs')) {
if (process.env.ENABLE_WEBLOG) {
const admins = {
admin: { password: process.env.ADMIN_PASS }
};
// ... some not authenticated middlewares.
const user = auth(req);
if (!user || !admins[user.name] || admins[user.name].password !== user.pass) {
res.set('WWW-Authenticate', 'Basic realm="example"');
return res.status(401).send();
}
} else {
await GBSSR.ssrFilter(req, res, next);
}
} else {
await GBSSR.ssrFilter(req, res, next);
}
}); });
GBLog.info(`The Bot Server is in RUNNING mode...`); GBLog.info(`The Bot Server is in RUNNING mode...`);