erikras / react-redux-universal-hot-example

A starter boilerplate for a universal webapp using express, react, redux, webpack, and react-transform
MIT License
11.99k stars 2.5k forks source link

Dont Work Http Proxy #1374

Open NightFury2 opened 7 years ago

NightFury2 commented 7 years ago
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

parth-choudhary commented 7 years ago

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);