yezihaohao / react-admin

:sparkles: react-admin system solution : react 后台管理系统解决方案
https://admiring-dijkstra-34cb29.netlify.com/
MIT License
6.65k stars 1.87k forks source link

请问webpack的代理怎么设置 #30

Closed SoraYao closed 6 years ago

SoraYao commented 6 years ago

在webpack.config.dev.js中添加了代理的相关设置,但是在测试环境中每次fetch的时候 请求地址还是没有成功代理,

devServer: { historyApiFallback: true, host: 'localhost', port: '3006', hot: true, inline: true, stats: { colors: true }, proxy: { '/api/*': { target: 'http://XXXXX', pathRewrite: {'^/api' : '/api'}, changeOrigin: true } } },

yezihaohao commented 6 years ago

可以直接设置package.json.https://github.com/yezihaohao/react-admin/issues/12#issuecomment-326169055