mirror of
https://github.com/verdaccio/verdaccio.git
synced 2025-02-21 07:29:37 +01:00
fix: doubled request logs in node.js >= 11 (#2012)
``` $ docker run -it --rm --name verdaccio -p 4873:4873 verdaccio/verdaccio warn --- config file - /verdaccio/conf/config.yaml warn --- Verdaccio started warn --- Plugin successfully loaded: verdaccio-htpasswd warn --- Plugin successfully loaded: verdaccio-audit warn --- http address - http://0.0.0.0:4873/ - verdaccio/4.9.1 http --> 200, req: 'GET https://registry.npmjs.org/execa' (streaming) http --> 200, req: 'GET https://registry.npmjs.org/execa', bytes: 0/119164 http <-- 200, user: null(172.17.0.1), req: 'GET /execa', bytes: 0/27224 http <-- 200, user: null(172.17.0.1), req: 'GET /execa', bytes: 0/27224 ```
This commit is contained in:
parent
8237775c93
commit
1e59b6aa6f
@ -216,7 +216,13 @@ export function log(req: $RequestExtend, res: $ResponseExtend, next: $NextFuncti
|
||||
_write.apply(res, arguments);
|
||||
};
|
||||
|
||||
let logHasBeenCalled = false;
|
||||
const log = function(): void {
|
||||
if (logHasBeenCalled) {
|
||||
return;
|
||||
}
|
||||
logHasBeenCalled = true;
|
||||
|
||||
const forwardedFor = req.headers['x-forwarded-for'];
|
||||
const remoteAddress = req.connection.remoteAddress;
|
||||
const remoteIP = forwardedFor ? `${forwardedFor} via ${remoteAddress}` : remoteAddress;
|
||||
|
Loading…
Reference in New Issue
Block a user