解决跨域需要在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

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-09-07
  • 2021-07-12
  • 2021-09-06
  • 2022-12-23
  • 2021-08-18
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-05-24
  • 2023-03-24
  • 2021-12-03
  • 2021-12-04
相关资源
相似解决方案