ecs-logging-nodejs
ecs-logging-nodejs copied to clipboard
url is used instead of originalUrl in http-foramtters helper functions
I used morgan with ecsFormat to record http requests in elasticsearch, but the url field is not accurate.
app.use("/base", router);
router.get("/:service", (req, res, next) => {...})
In this example, req.url is /:service and req.originalUrl is /base/:service, because req.url is changed when the router is mounted to /base. formatHttpRequest
helper function uses req.url when formatting url, so that baseUrl is ignored. It should use req.originalUrl instead of req.url.
Any progress on this? I have the same problem...
Thank you for the issue and my apologies for the delay.
https://expressjs.com/en/4x/api.html#req.originalUrl
When using Express, this library needs to prefer req.originalUrl
because Express overwrites req.url
during its routing.