Umi配置proxy解决跨域问题

解决跨域需要在webpack配置proxy,
umi将webpack配置保存在.umirc.js的配置文件中。
.umirc.js文件加上:

proxy: {
    '/api': {
      target: 'http://localhost:9093',
      pathRewrite: { '^/api': '' },
      changeOrigin: true
    }
  }

本地8000发送请求http://localhost:8000/api/data请求的数据其实是http://localh ost:9093/data

原文地址:https://www.cnblogs.com/sexintercourse/p/13831206.html