Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

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

wants to merge 1 commit into from

Conversation

FraBle
Copy link

@FraBle FraBle commented Mar 2, 2018

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Middleware resets req.url on res.send() and prevents further middleware to execute
1 participant