Skip to content

Commit

Permalink
fix(core.gbapp): /logs working again.
Browse files Browse the repository at this point in the history
  • Loading branch information
rodrigorodriguez committed Mar 27, 2023
1 parent 0c44361 commit d08e11f
Showing 1 changed file with 16 additions and 17 deletions.
33 changes: 16 additions & 17 deletions src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -212,32 +212,31 @@ export class GBServer {
await minService.buildMin(instances);

if (process.env.ENABLE_WEBLOG) {
const admins = {
admin: { password: process.env.ADMIN_PASS }
};
// If global log enabled, reorders transports adding web logging.

const loggers = GBLog.getLogger();
winston.default(server, loggers[1]);
}

// ... some not authenticated middlewares
server.get('*', async (req, res, next) => {
if (req.originalUrl.startsWith('/logs')) {
if (process.env.ENABLE_WEBLOG) {
const admins = {
admin: { password: process.env.ADMIN_PASS }
};

server.use(async (req, res, next) => {
if (req.originalUrl.startsWith('/logs')) {
// ... 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 {
return next();
await GBSSR.ssrFilter(req, res, next);
}
});

// If global log enabled, reorders transports adding web logging.

const loggers = GBLog.getLogger();
winston.default(server, loggers[1]);
}

server.get('*', async (req, res, next) => {
await GBSSR.ssrFilter(req, res, next);
} else {
await GBSSR.ssrFilter(req, res, next);
}
});

GBLog.info(`The Bot Server is in RUNNING mode...`);
Expand Down

0 comments on commit d08e11f

Please sign in to comment.