vue解决外网IP访问以及域名访问出现invalid host header 问题
正常的vue搭建完成以后npm run dev就可以localhost:8080访问开发了但是有时候你想用IP形式访问的话你可以这样做1.修改配置config/index.jshost:'0.0.0.0'完成了这一步就可以用iP地址访问开发了;但是有时候需要用域名访问,此时用域名访问会出现invalid host header 解决这个问题我们可以这样做:2.在build/webpa...
正常的vue搭建完成以后npm run dev就可以localhost:8080访问开发了
但是有时候你想用IP形式访问的话你可以这样做
1.修改配置config/index.js
host:'0.0.0.0'
完成了这一步就可以用iP地址访问开发了;
但是有时候需要用域名访问,此时用域名访问会出现invalid host header
解决这个问题我们可以这样做:
2.在build/webpack.dev.conf.js中添加:disableHostCheck: true
devServer: {
public: 'local.kingsum.biz',
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
watchOptions: {
poll: config.dev.poll,
},
disableHostCheck: true 加上这段
}
更多推荐
所有评论(0)