代理Localhost请求在Debian OS上使用nodejs使用PARCELJ时会遇到Econnreset错误

发布于 2025-02-02 14:44:59 字数 1525 浏览 4 评论 0 原文

我在不同端口上有2个应用程序。

  1. API -http:// localhost:3000
  2. UI- http:// localhost:3001

UI通过

我需要将UI应用程序(3001)的所有请求转发到API(3000)

我尝试使用.proxyrc方法 https://parcelceljs.s.org/features/features/deflovement/deflovement/#。 proxyrc-%2f-.proxyrc.json 使用下一个配置:

{
    "/api": {
        "target": "http://localhost:3000/",
        "changeOrigin": true
    }
}

另外,我尝试使用.proxyrc.js

const { createProxyMiddleware } = require("http-proxy-middleware")

module.exports = function (app) {
  app.use(
    createProxyMiddleware("/api", {
      target: "http://localhost:3000/",
      changeOrigin: true,
    })
  );
};

不幸的是,每次请求时我会遇到这样的错误:

console: [HPM] Error occurred while proxying request localhost:3001/api/v2/client-config to http://localhost:3000/ [ECONNRESET] (https://nodejs.org/api/errors.html#errors_common_system_errors)

其他带有Debian和其他Linuxes的团队成员没有此类问题。

有人可以帮我吗?

  • OS:Debian GNU/Linux 11(Bullseye)
  • NVM:0.39.1
  • 节点:V14.18.2
  • NPM:8.3.1
  • HTTP-Proxy-Middleware: ^2.0.6

I have 2 apps running on different ports.

  1. API - http://localhost:3000
  2. UI - http://localhost:3001

UI is running via dev mode of parcel.

I need to forward all requests from UI app (3001) to API (3000)

I tried to use .proxyrc approach
https://parceljs.org/features/development/#.proxyrc-%2F-.proxyrc.json
with next configuration:

{
    "/api": {
        "target": "http://localhost:3000/",
        "changeOrigin": true
    }
}

Also, I tried using .proxyrc.js https://parceljs.org/features/development/#.proxyrc.js

const { createProxyMiddleware } = require("http-proxy-middleware")

module.exports = function (app) {
  app.use(
    createProxyMiddleware("/api", {
      target: "http://localhost:3000/",
      changeOrigin: true,
    })
  );
};

Unfortunately every time I get such an error when a request comes:

console: [HPM] Error occurred while proxying request localhost:3001/api/v2/client-config to http://localhost:3000/ [ECONNRESET] (https://nodejs.org/api/errors.html#errors_common_system_errors)

Other team members with Debian and other linuxes have no such issues.

Could someone help me with that please ?

  • OS: Debian GNU/Linux 11 (bullseye)
  • nvm: 0.39.1
  • node: v14.18.2
  • npm: 8.3.1
  • http-proxy-middleware: ^2.0.6

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文