"proxy": "http://localhost:3001"
в моем package.json
где экспресс-сервер работает на этом порту (3001), но каждый раз, когда я нажимаю на запрос от реакции, он идет на порт 3000, на котором запущено приложение реакции
package.json
{
"name": "client",
"version": "0.1.0",
"private": true,
"dependencies": {
"antd": "^3.10.2",
"axios": "^0.18.0",
"dotenv": "^6.1.0",
"http-proxy-middleware": "^0.19.0",
"material-ui": "^0.20.2",
"react": "^16.5.2",
"react-bootstrap": "^0.32.4",
"react-dom": "^16.5.2",
"react-form": "^3.5.6",
"react-redux": "^5.0.4",
"react-router-dom": "^4.3.1",
"react-router-redux": "^5.0.0-alpha.5",
"react-scripts": "2.0.5",
"styled-components": "^4.0.2"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
"eslintConfig": {
"extends": "react-app"
},
"browserslist": [
">0.2%",
"not dead",
"not ie <= 11",
"not op_mini all"
]
}
setupProxy.js
const proxy = require('http-proxy-middleware');
module.exports = function(app) {
app.use(proxy('/api/*', { target: 'http://localhost:3001' }));
};