Expected behavior
I have two running dev servers on localhost. I need to proxy a request from localhost:4000 to subdomain.localhost:3000
Actual behavior
On server launch I receive:
[HPM] Proxy created: / -> http://agent.localhost:3000
On request I see following message in console:
[HPM] Error occurred while trying to proxy request /config from localhost:4000 to http://agent.localhost:3000 (ENOTFOUND) (https://nodejs.org/api/errors.html#errors_common_system_errors)
And in a browser I receive following 504 response:
Error occurred while trying to proxy to: localhost:4000/config
At the same time requesting that endpoint in Chrome works fine.
Setup
- http-proxy-middleware: 0.18.0
- server: express@4.16.2
- webpack-dev-middleware@3.1.0
proxy middleware configuration
app.use(require('webpack-dev-middleware')(compiler, {
noInfo: true,
publicPath: config.output.publicPath
}));
app.use(require('webpack-hot-middleware')(compiler));
config.devServer.proxyConf.endpoints.forEach((endpoint) => {
app.use(endpoint, proxy(config.devServer.proxyConf.config));
});
proxyConf: {
endpoints: [
"/config",
],
config: {
target: "http://agent.localhost:3000",
secure: false,
changeOrigin: true
},
}
server mounting
app.listen(port, function (err) {
if(err) {
console.log(`Error during app launch: ${err.message}`.red);
} else {
console.log(`Server is listening on ${port}...`.green);
}
});
Expected behavior
I have two running dev servers on localhost. I need to proxy a request from
localhost:4000tosubdomain.localhost:3000Actual behavior
On server launch I receive:
[HPM] Proxy created: / -> http://agent.localhost:3000On request I see following message in console:
[HPM] Error occurred while trying to proxy request /config from localhost:4000 to http://agent.localhost:3000 (ENOTFOUND) (https://nodejs.org/api/errors.html#errors_common_system_errors)And in a browser I receive following
504response:Error occurred while trying to proxy to: localhost:4000/configAt the same time requesting that endpoint in Chrome works fine.
Setup
proxy middleware configuration
server mounting