Skip to content

Commit

Permalink
Add user-agent to request logs
Browse files Browse the repository at this point in the history
  • Loading branch information
cskrov committed Dec 22, 2023
1 parent 838428c commit bf46599
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions server/src/logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ export const httpLoggingMiddleware: RequestHandler = (req, res, next) => {
res.once('finish', () => {
const { method, url } = req;
const referrer = req.get('referrer');
const userAgent = req.get('user-agent');

if (url.endsWith('/isAlive') || url.endsWith('/isReady')) {
return;
Expand All @@ -125,6 +126,7 @@ export const httpLoggingMiddleware: RequestHandler = (req, res, next) => {
url,
statusCode,
referrer,
userAgent,
responseTime,
});
});
Expand All @@ -138,6 +140,7 @@ interface HttpData extends AnyObject {
statusCode: number;
responseTime: number;
referrer?: string;
userAgent?: string;
}

const logHttpRequest = (data: HttpData) => {
Expand Down

0 comments on commit bf46599

Please sign in to comment.