Skip to content

Commit f705915

Browse files
committed
Restore setting windows host to localhost
1 parent 97d58a6 commit f705915

File tree

2 files changed

+5
-13
lines changed

2 files changed

+5
-13
lines changed

packages/gatsby-cli/src/create-cli.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ const handlerP = fn => (...args) => {
1414
}
1515

1616
function buildLocalCommands(cli, isLocalSite) {
17-
const defaultHost = `0.0.0.0`
17+
const defaultHost = process.platform === "win32" ? "localhost" : "0.0.0.0"
1818
const directory = path.resolve(`.`)
1919

2020
let siteInfo = { directory, browserslist: DEFAULT_BROWSERS }

packages/gatsby/src/commands/develop.js

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -254,9 +254,8 @@ module.exports = async (program: any) => {
254254
})
255255

256256
const isUnspecifiedHost = host === `0.0.0.0` || host === `::`
257-
let prettyHost, lanUrlForConfig, lanUrlForTerminal
257+
let lanUrlForConfig, lanUrlForTerminal
258258
if (isUnspecifiedHost) {
259-
prettyHost = `localhost`
260259
try {
261260
// This can only return an IPv4 address
262261
lanUrlForConfig = address.ip()
@@ -278,14 +277,12 @@ module.exports = async (program: any) => {
278277
} catch (_e) {
279278
// ignored
280279
}
281-
} else {
282-
prettyHost = host
283280
}
284281
// TODO collect errors (GraphQL + Webpack) in Redux so we
285282
// can clear terminal and print them out on every compile.
286283
// Borrow pretty printing code from webpack plugin.
287-
const localUrlForTerminal = prettyPrintUrl(prettyHost)
288-
const localUrlForBrowser = formatUrl(prettyHost)
284+
const localUrlForTerminal = prettyPrintUrl(host)
285+
const localUrlForBrowser = formatUrl(host)
289286
return {
290287
lanUrlForConfig,
291288
lanUrlForTerminal,
@@ -318,11 +315,6 @@ module.exports = async (program: any) => {
318315
console.log()
319316
}
320317

321-
const host =
322-
listener.address().address === `127.0.0.1`
323-
? `localhost`
324-
: listener.address().address
325-
326318
let isFirstCompile = true
327319
// "done" event fires when Webpack has finished recompiling the bundle.
328320
// Whether or not you have warnings or errors, you will get this event.
@@ -331,7 +323,7 @@ module.exports = async (program: any) => {
331323
// options so we are going to "massage" the warnings and errors and present
332324
// them in a readable focused way.
333325
const messages = formatWebpackMessages(stats.toJson({}, true))
334-
const urls = prepareUrls(`http`, host, port)
326+
const urls = prepareUrls(`http`, program.host, program.port)
335327
const isSuccessful = !messages.errors.length && !messages.warnings.length
336328
// if (isSuccessful) {
337329
// console.log(chalk.green(`Compiled successfully!`))

0 commit comments

Comments
 (0)