react-redux-universal-hot-example icon indicating copy to clipboard operation
react-redux-universal-hot-example copied to clipboard

Dont Work Http Proxy

Open NightFury2 opened this issue 8 years ago • 1 comments
trafficstars

const targetUrl = config.apiHost + config.apiPort; 
const proxy = httpProxy.createProxyServer({ target: targetUrl });
 // Proxy to API server app.use('/api', (req, res) => { 
     console.log(req.originalUrl); 
     console.log(targetUrl); 
    proxy.web(req, res, {target: targetUrl}); 
});

Why http proxy send a request to the right address, and receives 404, and if you open the same address through brouser gets json. checked through console.log the issue the required address

NightFury2 avatar Mar 01 '17 11:03 NightFury2

Works fine for me, can you tell us what are the values for config.apiHost & config.apiPort? And the outputs of

console.log(req.originalUrl); 
console.log(targetUrl);

parth-choudhary avatar Jul 02 '17 17:07 parth-choudhary