vue-cli 解决跨域

2021-11-08  本文已影响0人  __鹿__

在项目根目录新建vue.config.js文件,加入以下代码即可。

module.exports = {
    publicPath: "",
    devServer: {
        port: 8888,
        proxy: {
          '/': {
            target: 'http://172.30.128.72:8080',
            ws: true,
            changeOrigin: true,
            pathRewrite: {
              '^/': ''
            }
          },
        },
        disableHostCheck: true, // 这是由于新版的webpack-dev-server出于安全考虑,默认检查hostname,如果hostname 不是配置内的,将中断访问。
  },
}
上一篇 下一篇

猜你喜欢

热点阅读