vue——webpack跨域设置

使用 vue-cli 创建vue项目,在config配置文件夹下的index.js中,dev属性中有关于跨域代理的 proxyTable 属性,默认为空属性,

    proxyTable: {
      '/api':{
        target:'http://localhost:3000', //目标URL地址
        changeOrigin: true, //是否跨域,默认为true
        pathRewrite: {
          '^/api': '/' //重写接口,把本地URL http://localhost:8080/api 转到 http://localhost:3000 根目录下
        }
      }
    },
    host: 'localhost', 
    port: 8080, 

猜你喜欢

转载自blog.csdn.net/YUHUI01/article/details/83692738
今日推荐