Configure React JS Proxy Manually
First, you need to create a middleware.
$ npm install http-proxy-middleware --save
$ # or
$ yarn add http-proxy-middleware
After you create a middleware we need to create a file in src/setupProxy.js and place the following content.
const { createProxyMiddleware } = require('http-proxy-middleware');
module.exports = function(app) {
app.use(
'/api',
createProxyMiddleware({
target: 'http://localhost:5000',
changeOrigin: true,
})
);
};
After that, you should all be good to go to call your API routes without including the whole path.
If you want more information follow this link: https://create-react-app.dev/docs/proxying-api-requests-in-development/