I have a node.js application that uses webpack-dev-server, so in my package.json I have this to start it:
...
"scripts": {
"start": "webpack-dev-server --host 192.168.0.13 --port 3001",
}
...
192.168.0.13
is my local IP address. As my network uses DHCP, is there a variable that I can use instead of my IP address in package.json or webpack.config.js file, so that it will always use my local IP?
Note: I have read that I can use 0.0.0.0
, but this is apparently insecure, so is there something else I can use directly in my package.json or webpack.config.js file that will dynamically provide webpack-dev-server
with my local IP address?
I discovered that the host can be dynamically set within webpack.config.js
using the host
option:
...
devServer: {
host: require('os').hostname().toLowerCase(),
port: 3001,
...
},
...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With