[英]Proxy error: Could not proxy request ... from localhost:3000 to http://localhost:5000/
How to fix the error below?如何修复下面的错误? Proxy error: Could not proxy request /api/auth/register from localhost:3000 to http://localhost:5000/.代理错误:无法代理请求 /api/auth/register 从 localhost:3000 到 http://localhost:5000/。 1 See https://nodejs.org/api/errors.html#errors_common_system_errors for more information (ECONNREFUSED). 1有关详细信息,请参阅https://nodejs.org/api/errors.html#errors_common_system_errors (ECONNREFUSED)。
Run backend and this error will be removed automatically.运行后端,此错误将自动删除。
You must have set "proxy": "http://localhost:5000/"
in your package.json in your client side.您必须在客户端的 package.json 中设置"proxy": "http://localhost:5000/"
。 What this does is that it prefixes every request with the proxy.这样做的目的是为每个请求加上代理前缀。
So this problem will arise if your backend server is listening at port other than 5000(since your every request will be directed at http://localhost:5000/<api>
)因此,如果您的后端服务器正在侦听 5000 以外的端口,则会出现此问题(因为您的每个请求都将指向http://localhost:5000/<api>
)
SOLUTION:解决方案:
either change the proxy to what your backend server is listening at or change the backend server's listening port to what the proxy is set at.要么将代理更改为您的后端服务器正在侦听的内容,要么将后端服务器的侦听端口更改为代理设置的内容。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.