It’s fairly simple, and very well documented, how to setup an express server with a CRA (Create React App) application. Simply add a line to the CRA’s package.json file:
"proxy": "http://localhost:3001",
But what happens when you eject from CRA? Once you do that, the webpack configs are entirely up to you. Your one-line proxy in package.json will not work anymore.
Instead, you’ll need to add a couple lines to your webpack.config.js file. This worked for me:
devServer: {
proxy: [
{
context: ['/api'],
target: 'http://localhost:3001',
},
],
},