Ant-design-pro: config proxy.pathRewrite 无效

Created on 22 Nov 2018  ·  5Comments  ·  Source: ant-design/ant-design-pro

issue

代理配置在npm start:no-mock测试中是起作用的,但是build生成的文件/api前缀没有被重写,我记得之前老版本是没有问题的,具体哪个版本我忘了。

config

  base: '/admin',
  publicPath: '/admin/',
  proxy: {
    '/api': {
      'target': 'http://localhost:8080',
      'changeOrigin': true,
      'pathRewrite': { '^/api' : '' }
    }
  }

service/api.js

// 自定义api
export async function login(param) {
  return axios.post('/api/users/login', param);
}

npm run build

umi.js
image

Most helpful comment

proxy只在代理的时候有效,pathRewrite指是否修改代理地址。不会改写文件。build之后proxy都是无效的。

All 5 comments

没有这个”老版本“,proxy,build之后一直是不可用的

我用的是最新版本2.1.1

没有这个”老版本“,proxy,build之后一直是不可用的

你好,我用的是2.1.1版本,这个版本也是不能用吗

proxy只在代理的时候有效,pathRewrite指是否修改代理地址。不会改写文件。build之后proxy都是无效的。

Snip20190402_14
nginx.conf

Was this page helpful?
0 / 5 - 0 ratings

Related issues

yadongxie150 picture yadongxie150  ·  3Comments

wuyongdec picture wuyongdec  ·  3Comments

ghost picture ghost  ·  3Comments

952425340 picture 952425340  ·  3Comments

gaoqiang19514 picture gaoqiang19514  ·  3Comments