ecs-logging-nodejs icon indicating copy to clipboard operation
ecs-logging-nodejs copied to clipboard

url is used instead of originalUrl in http-foramtters helper functions

Open blue-int opened this issue 3 years ago • 1 comments

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.

blue-int avatar Dec 20 '21 18:12 blue-int

Any progress on this? I have the same problem...

marcin-wlodarczyk avatar Feb 23 '22 11:02 marcin-wlodarczyk

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.

trentm avatar Oct 30 '23 21:10 trentm