乐趣区

关于代理:vue2x-配置代理-proxy

vue2.x 本地开发配置代理

1、关上我的项目中 config -> index.js 文件

2、批改 proxyTable 中的内容

proxyTable: {
      "/service-core": {
        // 把 localhost:8080 代理为上面的地址
        target: "https://test.eastgrain.cn", // localhost:8080 代理为这个地址
        secure: true, // 如果是 https,须要配置 true
        changeOrigin: true, // 是否跨域
        // pathRewrite: {   // 重写,如果开发环境地址中不须要 service-core,那么能够将其重写为 ''//"^/service-core":""
        // }
      }
      // 想要代理的地址:'localhost:8080/service-core/wechat/serviceAccount/qrCode/create'
      // 代理后的地址 'https://test.eastgrain.cn/service-core/wechat/serviceAccount/qrCode/create'
      // axios 申请接口写法 axios.get('/service-core/wechat/serviceAccount/qrCode/create')...
}

依照下面的办法能够配置多个代理。

3、重启我的项目,就能够实现本地代理了。

退出移动版