req.originalUrl
req.url is not a native Express property, it is inherited from Node’s http module.
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.
// GET /search?q=something
console.dir(req.originalUrl)
// => '/search?q=something'
req.originalUrl is available both in middleware and router objects, and is a combination of req.baseUrl and req.url. Consider following example:
app.use('/admin', function (req, res, next) { // GET 'http://www.example.com/admin/new?sort=desc'
console.dir(req.originalUrl) // '/admin/new?sort=desc'
console.dir(req.baseUrl) // '/admin'
console.dir(req.path) // '/new'
next()
})
req.url
req.originalUrl
req.baseUrl
req.path
의 차이는???