Sometimes, we want to get the hostname of current request in Node.js Express.
In this article, we’ll look at how to get the hostname of current request in Node.js Express.
How to get the hostname of current request in Node.js Express?
To get the hostname of current request in Node.js Express, we can use the os.hostname method.
For instance, we write
const os = require("os");
os.hostname();
to call os.hostname to return the hostname of the current request.
Conclusion
To get the hostname of current request in Node.js Express, we can use the os.hostname method.