使用 Docker 代理对 Flask 应用程序的响应请求

时间:2021-04-27 22:57:57

标签: reactjs docker flask reverse-proxy

我创建了一个 Docker 容器,其中包含一个 React 应用程序和一个 Flask 应用程序。到目前为止,我收到错误:Proxy error: Could not proxy request /backend_endpoint from localhost:3000 to http://api:5000. 在我的 package.json 中,我有 "proxy": "http://api:5000" 行。我在另一篇文章中读到您应该在 localhost:5000 中将 container_name:5000 重命名为 package.json,这就是我拥有 "proxy": "http://api:5000", 的原因。我将不胜感激任何建议/见解!谢谢。这是我的docker-compose.yml

updated docker-compose.yml
```version: '3.7'
services:
   client:
      build:
         context: ./react-app
         dockerfile: Dockerfile
      tty: true
      ports:
         - "3000:3000"
      volumes:
         - ./react-app:/app
         - /app/node_modules

   api:
      build:
         context: ./react-app/api
         dockerfile: Dockerfile
      ports:
         - "5000:5000"```

错误信息:Proxy error: Could not proxy request /user_entry from localhost:3000 to http://api:5000. See https://nodejs.org/api/errors.html#errors_common_system_errors for more information (ECONNREFUSED).

0 个答案:

没有答案
相关问题