美文网首页
vue项目设置域名代理

vue项目设置域名代理

作者: muroujue | 来源:发表于2018-05-15 10:36 被阅读0次

通过vue-cli搭建了vue项目脚手架之后,修改了端口port值,想使用whistle设置个域名代理,发现运行之后报错。

报错图片.png
排查之后发现是webpack时做了域名检测,解决方案:
对build/webpack.dev.conf.js中的devServer设置 webpack-dev-server 的配置项 disableHostCheck 为 true 以禁用这一检测,如果开发者使用了代理,或在开发环境中不 care 这些安全问题,该设置可以直接斩草除根。
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,
    },
    disableHostCheck: true   //加入这段
  }

相关文章

网友评论

      本文标题:vue项目设置域名代理

      本文链接:https://www.haomeiwen.com/subject/galedftx.html