[英]Docker proxy error: Could not proxy request /api/product/B002QYW8LW from localhost:3000 to http://localhost:5000
I am trying to host my app through docker, but got this error:我正在尝试通过 docker 托管我的应用程序,但出现此错误:
client_1 | Proxy error: Could not proxy request /api/product/B002QYW8LW from localhost:3000 to http://localhost:5000.
client_1 | See https://nodejs.org/api/errors.html#errors_common_system_errors for more information (ECONNREFUSED).
With the below settings, it works for me locally.使用以下设置,它在本地适用于我。 I searched this through google and it seems to be relevent to the proxy settings.
我通过谷歌搜索了这个,它似乎与代理设置有关。 Some people was able to set the proxy as an object, but it gaves me an error saying proxy needs to be a string.
有些人能够将代理设置为 object,但它给了我一个错误,说代理需要是一个字符串。 That's why I decided to ask this question here again.
这就是为什么我决定再次在这里问这个问题。 Can someone please help out?
有人可以帮忙吗?
I have deleted irrelavent stuff in package.json to save space.为了节省空间,我删除了 package.json 中无关紧要的东西。
package.json for server: package.json 用于服务器:
{
"name": "",
"version": "",
"description": "",
"main": "src/server.js",
"scripts": {
},
"repository": {
},
"author": "",
"license": "",
"bugs": {
},
"homepage": ""
"dependencies": {},
"devDependencies": {
}
}
package.json for client: package.json 客户端:
{
"name": "client",
"version": "0.1.0",
"private": true,
"dependencies": {
},
"scripts": {
},
"eslintConfig": {
},
"browserslist": {
"production": [],
"development": []
},
"proxy": "http://localhost:5000"
}
Containers:容器:
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
e4b55b165c9a productfetching_client "npm start" 24 hours ago Up 24 hours 0.0.0.0:3000->3000/tcp productfetching_client_1
10581d34d189 productfetching_server "node server.js" 24 hours ago Up 24 hours 0.0.0.0:5000->5000/tcp productfetching_server_1
Use the container name registered in docker-compose file as said in a comment or http://0.0.0.0:PORT
instead which point to the local container network address, instead of localhost or 127.0.0.1 which point to your regular machine network.使用在 docker-compose 文件中注册的容器名称,如评论或
http://0.0.0.0:PORT
中所述,它指向本地容器网络地址,而不是 localhost 或 127.0.0.1 指向您的常规机器网络。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.