diff --git a/packages/react-dev-utils/WebpackDevServerUtils.js b/packages/react-dev-utils/WebpackDevServerUtils.js index 4fcd719087..02ce10f3e9 100644 --- a/packages/react-dev-utils/WebpackDevServerUtils.js +++ b/packages/react-dev-utils/WebpackDevServerUtils.js @@ -52,9 +52,22 @@ function prepareUrls(protocol, host, port) { if (isUnspecifiedHost) { prettyHost = 'localhost'; try { + // This can only return an IPv4 address lanUrlForConfig = address.ip(); if (lanUrlForConfig) { - lanUrlForTerminal = prettyPrintUrl(lanUrlForConfig); + // Check if the address is a private ip + // https://en.wikipedia.org/wiki/Private_network#Private_IPv4_address_spaces + if ( + /^10[.]|^172[.](1[6-9]|2[0-9]|3[0-1])[.]|^192[.]168[.]/.test( + lanUrlForConfig + ) + ) { + // Address is private, format it for later use + lanUrlForTerminal = prettyPrintUrl(lanUrlForConfig); + } else { + // Address is not private, so we will discard it + lanUrlForConfig = undefined; + } } } catch (_e) { // ignored