Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Restore setting windows host to localhost #2983

Merged
merged 2 commits into from
Nov 21, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/gatsby-cli/src/create-cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const handlerP = fn => (...args) => {
}

function buildLocalCommands(cli, isLocalSite) {
const defaultHost = `0.0.0.0`
const defaultHost = process.platform === `win32` ? `localhost` : `0.0.0.0`
const directory = path.resolve(`.`)

let siteInfo = { directory, browserslist: DEFAULT_BROWSERS }
Expand Down
16 changes: 4 additions & 12 deletions packages/gatsby/src/commands/develop.js
Original file line number Diff line number Diff line change
Expand Up @@ -254,9 +254,8 @@ module.exports = async (program: any) => {
})

const isUnspecifiedHost = host === `0.0.0.0` || host === `::`
let prettyHost, lanUrlForConfig, lanUrlForTerminal
let lanUrlForConfig, lanUrlForTerminal
if (isUnspecifiedHost) {
prettyHost = `localhost`
try {
// This can only return an IPv4 address
lanUrlForConfig = address.ip()
Expand All @@ -278,14 +277,12 @@ module.exports = async (program: any) => {
} catch (_e) {
// ignored
}
} else {
prettyHost = host
}
// TODO collect errors (GraphQL + Webpack) in Redux so we
// can clear terminal and print them out on every compile.
// Borrow pretty printing code from webpack plugin.
const localUrlForTerminal = prettyPrintUrl(prettyHost)
const localUrlForBrowser = formatUrl(prettyHost)
const localUrlForTerminal = prettyPrintUrl(host)
const localUrlForBrowser = formatUrl(host)
return {
lanUrlForConfig,
lanUrlForTerminal,
Expand Down Expand Up @@ -318,11 +315,6 @@ module.exports = async (program: any) => {
console.log()
}

const host =
listener.address().address === `127.0.0.1`
? `localhost`
: listener.address().address

let isFirstCompile = true
// "done" event fires when Webpack has finished recompiling the bundle.
// Whether or not you have warnings or errors, you will get this event.
Expand All @@ -331,7 +323,7 @@ module.exports = async (program: any) => {
// options so we are going to "massage" the warnings and errors and present
// them in a readable focused way.
const messages = formatWebpackMessages(stats.toJson({}, true))
const urls = prepareUrls(`http`, host, port)
const urls = prepareUrls(`http`, program.host, program.port)
const isSuccessful = !messages.errors.length && !messages.warnings.length
// if (isSuccessful) {
// console.log(chalk.green(`Compiled successfully!`))
Expand Down