mirror of
https://github.com/nuxt/nuxt.git
synced 2025-01-30 23:32:38 +00:00
fix: show localhost instead of 0.0.0.0 in Open URL
fixes potential problems after merging #865
This commit is contained in:
parent
e2dac5f3aa
commit
affcb9d58e
@ -427,8 +427,9 @@ function getWebpackServerConfig () {
|
|||||||
|
|
||||||
function createWebpackMiddleware () {
|
function createWebpackMiddleware () {
|
||||||
const clientConfig = getWebpackClientConfig.call(this)
|
const clientConfig = getWebpackClientConfig.call(this)
|
||||||
const host = process.env.HOST || process.env.npm_package_config_nuxt_host || '127.0.0.1'
|
const host = process.env.HOST || process.env.npm_package_config_nuxt_host || 'localhost'
|
||||||
const port = process.env.PORT || process.env.npm_package_config_nuxt_port || '3000'
|
const port = process.env.PORT || process.env.npm_package_config_nuxt_port || '3000'
|
||||||
|
|
||||||
// setup on the fly compilation + hot-reload
|
// setup on the fly compilation + hot-reload
|
||||||
clientConfig.entry.app = _.flatten(['webpack-hot-middleware/client?reload=true', clientConfig.entry.app])
|
clientConfig.entry.app = _.flatten(['webpack-hot-middleware/client?reload=true', clientConfig.entry.app])
|
||||||
clientConfig.plugins.push(
|
clientConfig.plugins.push(
|
||||||
@ -436,7 +437,10 @@ function createWebpackMiddleware () {
|
|||||||
new webpack.NoEmitOnErrorsPlugin(),
|
new webpack.NoEmitOnErrorsPlugin(),
|
||||||
new PostCompilePlugin(stats => {
|
new PostCompilePlugin(stats => {
|
||||||
if (!stats.hasErrors() && !stats.hasWarnings()) {
|
if (!stats.hasErrors() && !stats.hasWarnings()) {
|
||||||
console.log(`> Open http://${host}:${port}\n`) // eslint-disable-line no-console
|
// We don't use os.host() here because browsers have special behaviour with localhost
|
||||||
|
// For example chrome allows Geolocation api only to https or localhost origins
|
||||||
|
let _host = host==='0.0.0.0' ? 'localhost' : host
|
||||||
|
console.log(`> Open http://${_host}:${port}\n`) // eslint-disable-line no-console
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
|
Loading…
Reference in New Issue
Block a user