记一次ant design pro配置axios代理

1.首先找到项目中的.webpackkrc.js文件,向里面添加代码

entry: "src/index.js",
    extraBabelPlugins: [
    "transform-runtime",
    "transform-decorators-legacy",
    "transform-class-properties",
    ["import", { "libraryName": "antd", "libraryDirectory": "es", "style": true }]
],
    env: {
    "development": {
        "extraBabelPlugins": [
            "dva-hmr"
        ]
    }
},
proxy: {
    "/api": {
        "target": "https://xxxxxx.cn/", //此处是要代理的地址
            "changeOrigin": true,
            "pathRewrite": { "^/api": "" }
    }
},

2.打开自己axios请求页面,当然都会做封装,请求地址直接写:'/api/desk/deskStatusInfos'

 

 

你可能感兴趣的:(react-native,ant,design,pro)