Skip to content

Commit 4332d38

Browse files
committed
Start the dev server at the specified host
Pass the host from environment variable as argument of the devServer's listen function instead of a field of options object. Set the default host to 0.0.0.0 instead of localhost.
1 parent 7d66ba1 commit 4332d38

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

packages/react-scripts/scripts/start.js

+3-4
Original file line numberDiff line numberDiff line change
@@ -267,15 +267,14 @@ function runDevServer(host, port, protocol) {
267267
ignored: /node_modules/
268268
},
269269
// Enable HTTPS if the HTTPS environment variable is set to 'true'
270-
https: protocol === "https",
271-
host: host
270+
https: protocol === "https"
272271
});
273272

274273
// Our custom middleware proxies requests to /index.html or a remote API.
275274
addMiddleware(devServer);
276275

277276
// Launch WebpackDevServer.
278-
devServer.listen(port, (err, result) => {
277+
devServer.listen(port, host, (err, result) => {
279278
if (err) {
280279
return console.log(err);
281280
}
@@ -292,7 +291,7 @@ function runDevServer(host, port, protocol) {
292291

293292
function run(port) {
294293
var protocol = process.env.HTTPS === 'true' ? "https" : "http";
295-
var host = process.env.HOST || 'localhost';
294+
var host = process.env.HOST || '0.0.0.0';
296295
setupCompiler(host, port, protocol);
297296
runDevServer(host, port, protocol);
298297
}

0 commit comments

Comments
 (0)