从端口 4200 到 Api Net Core 2.1 后端使用的任何端口的 Angular 8 (ECONNRESET) 代理错误

问题描述

我看到有人问过这个问题,但就我而言,我已经尝试过我认为所有答案都没有成功。我必须通过团队正在开发的应用程序中的 VPN 使用 Windows 凭据进行身份验证,然后当我们想要测试更改时,我们执行 ng serve --port 4200 --proxy-config proxy.config.js 我们都明白了..

[HPM] 尝试将请求 http://localhost:4200/api/users/currentuser 从 localhost:4200 代理到 http://localhost:4200 (ECONNRESET) (https://nodejs.org/api/errors.html#errors_common_system_errors )

我们通过部署到后端 NET Core Web 项目 wwwroot 文件夹来解决这个问题,但是我们失去了 ng serve 和 Angular Development Live Server 的调试功能。每次构建和复制以可视化前端的任何大小变化都是非常耗时的。有趣的是,团队中有一个人可以从 http://localhost:4200

提供完整的 Angular 应用程序

我们一直在使用 thoguh VPN,因此不确定直接连接到公司网络的行为如何。

我只使用 api 和 graphql 上下文,这是我的代理文件

const Agent = require('agentkeepalive');
// I tried also with NTLM version with same issue result
// const Agent = require('agentkeepalive-ntlm');

module.exports = {
        '/api': {
            target: 'http://localhost:53904',secure: false,pathRewrite : {"^/api" : "http://localhost:53904/api"},agent: new Agent({
                maxSockets: 100,keepAlive: true,maxFreeSockets: 10,keepAliveMsecs: 100000,timeout: 6000000,keepAliveTimeout: 90000
            }),onProxyRes: proxyRes => {
                let key = 'www-authenticate';
                proxyRes.headers[key] = proxyRes.headers[key] &&
                    proxyRes.headers[key].split(',');
            }
        },'/graphql': {
        target: 'http://localhost:53904',pathRewrite : {"^/graphql" : "http://localhost:53904/graphql"},agent: new Agent({
            maxSockets: 100,keepAliveTimeout: 90000
        }),onProxyRes: proxyRes => {
            let key = 'www-authenticate';
            proxyRes.headers[key] = proxyRes.headers[key] &&
                proxyRes.headers[key].split(',');
        }
    }
};

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)