解決 vue 專案啟動後不能被外部IP訪問
阿新 • • 發佈:2018-12-18
解決 webpack-dev-serveri 啟動後通過外部訪問報錯 invalid host header
修改 config/index.js 的 host 屬性為 ‘0.0.0.0’
{
// ...,
host: '0.0.0.0',
port: 8080,
// ...
}
修改 build/webpack.dev.conf.js 的 devServer 配置
增加 disableHostCheck = true
devServer: {
clientLogLevel: 'warning',
historyApiFallback: true,
hot: true,
compress: true,
host: HOST || config.dev.host,
port: PORT || config.dev.port,
open: config.dev.autoOpenBrowser,
overlay: config.dev.errorOverlay
? { warnings: false, errors: true }
: false,
publicPath: config.dev.assetsPublicPath,
proxy: config.dev.proxyTable,
quiet: true , // necessary for FriendlyErrorsPlugin
disableHostCheck: true,
watchOptions: {
poll: config.dev.poll,
}
}