I used http-proxy-middle for proxying my api domain in order to bypass CORS issue. My code works in localhost, but when it is not working in my live domain.
My code is:
const proxy = require('http-proxy-middleware');
app.use(
'/api',
proxy({
target: ' mylivedomain.com',
pathRewrite: {
'^/api': '/',
},
changeOrigin: true,
logLevel: 'debug',
secure: false,
}),
);
I checked in the network tab, I got a status code: 302 when trying to GET or POST method. Does anyone have any ideas how to fix it?