Once or twice a week, a Docker question comes up roughly like:
I am running a React application and an Express backend in Docker Compose. I have a Docker network configured. My React application calls
fetch('http://backend/')
using the Compose service name; why doesn't this work?
Some recent questions more or less of this form include this (using websockets), this (pure Node.js/MongoDB stack), this (misuses Docker-internal IP address), this (Axios), this (fairly clear example, Axios/Flask).
There is a good technical explanation to this (the application runs in the browser even if it is served from a container) and two reasonable answers (better is to run a reverse proxy; acceptable in a local environment is to publish a port from the backend container).
I haven't found a really clear highly-scored question that lays out the problem clearly, making it clear it's not dependent on the JavaScript browser library or the backend technology. I also haven't found a solid answer that describes the reverse-proxy setup. Is there a "best" question for this class of question?
(I'd also hope for a similar Kubernetes question, that has a better best answer using the Kubernetes Ingress system.)