req.originalUrl
From the Express docs:
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.
In almost all cases, you’ll want to use req.url
instead. In the rare cases where req.url
is modified (for example, inside of a policy or middleware in order to redirect to an internal route), req.originalUrl
will give you the URL that was originally requested.
req.originalUrl;
// => "/search"