Skip to content

Commit 9452e7e

Browse files
Timerromaindso
authored andcommitted
Prefer localhost as an address (facebook#2154)
1 parent 4bfc45a commit 9452e7e

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

packages/react-scripts/scripts/start.js

+14-1
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,19 @@ function run(port) {
6060
pathname: '/',
6161
});
6262

63+
let prettyHost;
64+
if (HOST === '0.0.0.0' || HOST === '::') {
65+
prettyHost = 'localhost';
66+
} else {
67+
prettyHost = HOST;
68+
}
69+
const prettyUrl = url.format({
70+
protocol,
71+
hostname: prettyHost,
72+
port,
73+
pathname: '/',
74+
});
75+
6376
// Create a webpack compiler that is configured with custom messages.
6477
const compiler = createWebpackCompiler(
6578
config,
@@ -100,7 +113,7 @@ function run(port) {
100113
console.log(chalk.cyan('Starting the development server...'));
101114
console.log();
102115

103-
openBrowser(formattedUrl);
116+
openBrowser(prettyUrl);
104117
});
105118
}
106119

0 commit comments

Comments
 (0)