Having trouble communicating between docker-compose services

后端 未结 2 1559
悲哀的现实
悲哀的现实 2021-01-28 04:39

I have the following docker-compose file:

version: \"3\"

services:
  scraper-api:
    build: ./ATPScraper
    volumes:
      - ./ATPScraper:/usr/sr         


        
2条回答
  •  星月不相逢
    2021-01-28 05:02

    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.

提交回复
热议问题