I have the following docker-compose
file:
version: \"3\"
services:
scraper-api:
build: ./ATPScraper
volumes:
- ./ATPScraper:/usr/sr
The React application runs in the end user's browser, which has no idea this "Docker" thing exists at all and doesn't know about any of the Docker Compose networking setup. For browser apps that happen to be hosted out of Docker, they need to be configured to use the host's DNS name or IP address, and the published port of the back-end service.
A common setup (Docker or otherwise) is to put both the browser apps and the back-end application behind a reverse proxy. In that case you can use relative URLs without host names like /api/...
, and they will be interpreted as "the same host and port", which bypasses this problem entirely.