Express.js req.subdomains Property Last Updated : 17 Mar, 2023 Comments Improve Suggest changes Like Article Like Report The req.subdomains property contains an array of subdomains in the domain name of the request. The application property subdomain offset, which defaults to 2 determines the beginning of the subdomain segments. Syntax: req.subdomains Parameter: No parameters. Returns: Array Installation of the express module: You can visit the link to Install the express module. You can install this package by using this command. npm install express After installing the express module, you can check your express version in the command prompt using the command. npm version express After that, you can just create a folder and add a file, for example, index.js. To run this file you need to run the following command. node index.js Project Structure: Example 1: Filename: index.js javascript const express = require('express'); const app = express(); const PORT = 3000; app.get('/', function (req, res) { console.log(req.subdomains); res.send(); }); app.listen(PORT, function (err) { if (err) console.log(err); console.log("Server listening on PORT", PORT); }); Steps to run the program: Make sure you have installed the express module using the following command: npm install express Run the index.js file using the below command: node index.js Output: Console Output: Server listening on PORT 3000 Browser Output: Now open your browser and go to http://localhost:3000/ , now you can see the following output on your console: Server listening on PORT 3000 [] Example 2: But if we had any other Host like car.lambo.example.com, then the output would be as shown below: Output: ['car', 'lambo'] Reference: Official Documentation Comment More infoAdvertise with us Next Article Express.js req.subdomains Property gouravhammad Follow Improve Article Tags : JavaScript Web Technologies Node.js Express.js Similar Reads Express.js req.signedCookies Property The req.signedCookies property contains signed cookies sent by the request, unsigned, and ready for use when using cookie-parser middleware. Syntax: req.signedCookies Parameter: No parameter Return Value: Object Installation of the express module: You can visit the link to Install the express mod 2 min read Express.js req.secure Property The req.secure property is a Boolean property that is true if a TLS connection is established else returns false. Syntax: req.secure Return Value: It returns a Boolean value either True or False. Installation of the express module: You can visit the link to Install the express module. You can inst 2 min read Express.js req.route Property The req.route property contains the currently-matched route which is a string. Syntax: req.route Parameter: No parameters. Return Value: Object Installation of the express module: You can visit the link to Install the express module. You can install this package by using this command. npm install 2 min read Express.js req.xhr Property The req.xhr property returns a true value if the requestâs X-Requested-With header field is XMLHttpRequest which indicates that the request was issued by a client library such as jQuery. Syntax: req.xhr Parameter: No parameters. Returns: True or False. Installation of the express module: You can 2 min read Express.js req.ip Property The req.ip property contains the remote IP address of the request. It is useful when the user wants the IP address of the incoming request made to the application. Syntax:req.ipParameter: No parameter. Return Value: String Installation of the express module:You can visit the link to Install the expr 2 min read Express.js req.ips Property The req.ips property contains an array of IP addresses specified in the X-Forwarded-For request header. It returns an array of IP addresses. Syntax: req.ips Parameter: No parameter. Return Value: Array Installation of the express module: You can visit the link to Install the express module. You ca 2 min read Express.js req.app Property The req.app property holds the reference to the instance of the Express application that is using the middleware. Syntax: req.app Parameter: No parameters. Return Value: Object Installation of the express module: You can visit the link to Install the express module. You can install this package b 2 min read Express.js res.app Property The res.app property holds a reference to the instance of the Express application that is using the middleware. Syntax: res.app Parameter: No parameters. Return Value: Object Installation of the express module: You can visit the link to Install the express module. You can install this package by 2 min read Express.js req.path Property The req.path property contains the path of the request URL. This property is widely used to get the path part of the incoming request URL. Syntax:req.pathParameter: No parameters. Return Value: String Installation of the express module:You can visit the link to Install the express module. You can in 2 min read Express res.locals Property The `res.locals` property is an object that holds response local variables specific to the current request. It has a scope limited to the request and is accessible only to the view(s) rendered during that particular request/response cycle, if any. Syntax:res.localsParameter: No parameters. Return Va 2 min read Like