express-winston icon indicating copy to clipboard operation
express-winston copied to clipboard

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

Open FraBle opened this issue 7 years ago • 0 comments

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.

FraBle avatar Mar 02 '18 22:03 FraBle