Proxy localhost:port -> subdomain.localhost:another_port doesn't work
See original GitHub issueExpected 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);
}
});
Issue Analytics
- State:
- Created 5 years ago
- Comments:6 (1 by maintainers)
Top Results From Across the Web
How can I reroute a sub-domain to localhost + port number?
I'm running IIS alongside Python development server. There are several server processes of different kinds. – urig. Jun 24, 2011 at 16:31.
Read more >Resolving subdomain.localhost doesn't work with docker swarm
What is the problem: can't get to container via subdomain. It works if I use port though; curl gives different results for subdomain...
Read more >Automatically forward subdomain to port on localhost - Help
I'm working with a microservices architecture and often have to spin up multiple front-ends running on different ports, the above config is ...
Read more >Usage - code-server v4.8.0 docs - Coder
If you're working on web services and want to access them locally, code-server can proxy to any port using either a subdomain or...
Read more >Proxy - Lando Docs
You can also tell Lando to scan additional ports with the moreHttpPorts key ... to health scan a localhost https address that doesn't...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I’ve hit this as well. My path is correct for the target server. I can hit the same endpoint in Chrome (
admin.localhost:8080
), but the proxy middleware will not route it.Update: I needed to add
admin.localhost
to my hosts file pointed to127.0.0.1
.putting my local subdomains on hosts file solved the issue to me, not the best solution but ok