vue cli引入微信sdk,完成微信接口调用——配置开发环境访问限制(四)

vue cli的单页项目很可能是无法直接代理就能够访问到,例如使用域名访问项目时报不合法的主机头,但是修改一个配置就可以使用ip映射访问了!

笔者是使用的webpack2.xx,在项目初始化时,根目录中有一个文件夹,找到build/webpack.dev.conf.js


devServer: {
clientLogLevel: 'warning',
historyApiFallback: {
rewrites: [
{ from: / . * /, to: path. posix. join( config. dev. assetsPublicPath, 'index.html') },
],
},
hot: true,
contentBase: false, // since we use CopyWebpackPlugin.
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,
}
}

在 devServer 对象下添加代码:

disableHostCheck: true

然后再次使用antapp的命令行配置一下,然后在浏览器中访问项目,如果正常访问,那就ok了!

猜你喜欢

转载自blog.csdn.net/museions/article/details/79507771
今日推荐