express-http-proxy
express-http-proxy copied to clipboard
Cannot proxy requests to another service within docker-compose
I created a proxy that works fine when running outside of a container but as soon as I try with docker compose I get 504 for all my requests:
const backendUri = process.env.BE_URI || "localhost" // either localhost or api in case of docker-compose
app.use(
baseUri,
proxy(`http://${backendUri}:8081`, {
proxyReqOptDecorator: (proxyReqOpts, srcReq) => {
// do something with request
return proxyReqOpts;
}
})
);
I have seen similar issues closed but none with a fix or a comment on how to fix it.
Is anyone able to help?
Thanks!
Could you post the docker-compose file?
Assuming you have had a look at https://docs.docker.com/compose/networking/