In a react app, one creates a setupProxy.js file and puts the following in it:
const proxy = require('http-proxy-middleware');
module.exports = function(app) {
app.use(proxy('/api/*',
{ target: 'http://localhost:5000/' }
));
}
But when I do the same thing and put this same file in a react native directory, the proxy doesn't work and I get network error from the client side. How does one setup a proxy in react native to connect with the server?
--- edit ---
I tried doing the following:
const endpointMiddleware = createEndpointMiddleware({
apis: {
default: {
apiUrl: 'localhost:5000/api/*',
},
},
});
const middlewares = [reduxThunk, endpointMiddleware, apiMiddleware];
const store = createStore(reducers, {}, applyMiddleware(...middlewares));
But this hasn't worked.