I've added the following setupProxy file according to the example in the docs:
const proxy = require('http-proxy-middleware');
module.exports = function (app) {
app.use(
'/address',
proxy({
target: 'https://zip-cloud.appspot.com/api',
changeOrigin: true,
})
);
};
But whenever I want to start the npm start command it fails with the following error: error Command failed with exit code 1.
I have no clue why it's not working. I'm using the newest CRA version and I'm using typescript. Any help would be appriciated!
Try:
const { createProxyMiddleware } = require('http-proxy-middleware');
module.exports = function (app) {
app.use(
'/address',
createProxyMiddleware({
target: 'https://zip-cloud.appspot.com/api',
changeOrigin: true,
})
);
};