req.route

req.route Contains the currently-matched route, a string. For example: app.get('/user/:id?', function userIdHandler(req, res) { console.log(req.route); res.send('GET'); }); Example output from the previous snippet: { path: '/user/:id?', stack: [ { handle: [Function: userIdHandler], name: 'userIdHandler', params: undefined, path: undefined, keys: [], regexp: /^\/?$/i, method: 'get' } ], methods: { get: true } }

req.query

req.query This property is an object containing a property for each query string parameter in the route. If there is no query string, it is the empty object, {}. // GET /search?q=tobi+ferret req.query.q // => "tobi ferret" // GET /shoes?order=desc&shoe[color]=blue&shoe[type]=converse req.query.order // => "desc" req.query.shoe.color // => "blue" req.query.shoe.type // => "converse"

req.path

req.path Contains the path part of the request URL. // example.com/users?sort=desc req.path // => "/users" When called from a middleware, the mount point is not included in req.path. See app.use() for more details.

req.protocol

req.protocol Contains the request protocol string: either http or (for TLS requests) https. When the trust proxy setting does not evaluate to false, this property will use the value of the X-Forwarded-Proto header field if present. This header can be set by the client or by the proxy. req.protocol // => "http"

req.params

req.params This property is an object containing properties mapped to the named route “parameters”. For example, if you have the route /user/:name, then the “name” property is available as req.params.name. This object defaults to {}. // GET /user/tj req.params.name // => "tj" When you use a regular expression for the route definition, capture groups are provided in the array using req.params[n], where n is the nth capture group. This rule is applied to unnamed wild card matches with string

req.param()

req.param(name [, defaultValue]) Deprecated. Use either req.params, req.body or req.query, as applicable. Returns the value of param name when present. // ?name=tobi req.param('name') // => "tobi" // POST name=tobi req.param('name') // => "tobi" // /user/tobi for /user/:name req.param('name') // => "tobi" Lookup is performed in the following order: req.params req.body req.query Optionally, you can specify defaultValue to set a default value if the parameter is not found in any o

req.originalUrl

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 req.originalUrl // => "/search?q=something"

req.method

req.method Contains a string corresponding to the HTTP method of the request: GET, POST, PUT, and so on.

req.ips

req.ips When the trust proxy setting does not evaluate to false, this property contains an array of IP addresses specified in the X-Forwarded-For request header. Otherwise, it contains an empty array. This header can be set by the client or by the proxy. For example, if X-Forwarded-For is client, proxy1, proxy2, req.ips would be ["client", "proxy1", "proxy2"], where proxy2 is the furthest downstream.

req.is()

req.is(type) Returns true if the incoming request’s “Content-Type” HTTP header field matches the MIME type specified by the type parameter. Returns false otherwise. // With Content-Type: text/html; charset=utf-8 req.is('html'); req.is('text/html'); req.is('text/*'); // => true // When Content-Type is application/json req.is('json'); req.is('application/json'); req.is('application/*'); // => true req.is('html'); // => false For more information, or if you have issues or concerns, see