关于代理: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、重启我的项目,就能够实现本地代理了。

评论

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

这个站点使用 Akismet 来减少垃圾评论。了解你的评论数据如何被处理