Skip to content

Commit

Permalink
Prefer localhost as an address (facebook#2154)
Browse files Browse the repository at this point in the history
  • Loading branch information
Timer committed May 15, 2017
1 parent b7c6086 commit e849171
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion scripts/start.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,19 @@ function run(port) {
pathname: '/',
});

let prettyHost;
if (HOST === '0.0.0.0' || HOST === '::') {
prettyHost = 'localhost';
} else {
prettyHost = HOST;
}
const prettyUrl = url.format({
protocol,
hostname: prettyHost,
port,
pathname: '/',
});

// Create a webpack compiler that is configured with custom messages.
const compiler = createWebpackCompiler(
config,
Expand Down Expand Up @@ -100,7 +113,7 @@ function run(port) {
console.log(chalk.cyan('Starting the development server...'));
console.log();

openBrowser(formattedUrl);
openBrowser(prettyUrl);
});
}

Expand Down

0 comments on commit e849171

Please sign in to comment.