bithavoc / express-winston

express.js middleware for winstonjs
https://www.npmjs.com/package/express-winston
MIT License
797 stars 187 forks source link

Use req.originalUrl instead of req.url for logs and don't manipulate req.url #170

Open FraBle opened 6 years ago

FraBle commented 6 years ago

The current implementation overwrites req.url since it is used in the log message templates. This leads to errors and issues like #156. In our case, it makes the Express app even crash.

This PR removes the overwrite of req.url and switches to req.originalUrl for the log messages. It resolves #156.

A little bit more context: The Express docs explain that req.url should only be changed for explicit desired internal routing purposes.

req.originalUrl

This property is much like req.url; however, it retains the original request URL, allowing you to rewrite req.url freely for internal routing purposes. For example, the “mounting” feature of app.use() will rewrite req.url to strip the mount point.