Skip to content

reasonix doctor api reach 在企业代理环境下必定失败 — DEFAULT_NO_PROXY 强制绕过代理导致直连超时 #1497

@Endererer

Description

@Endererer

环境

  • Reasonix 版本: 0.48.1
  • Node.js: v24.14.0
  • 网络环境: 公司内网,无法直连公网,所有 HTTPS 请求必须通过企业代理

复现步骤

配置好 DEEPSEEK_API_KEY

export https_proxy=公司代理
reasonix doctor

预期结果

api reach 检查通过,余额正常显示。

实际结果

✗ api reach /user/balance returned null — auth failed or network blocked

根因

DEFAULT_NO_PROXY 硬编码了 api.deepseek.com 和 *.deepseek.com:

// 推测源码位置:src/cli/proxy.ts
var DEFAULT_NO_PROXY = [
"api.deepseek.com",
"*.deepseek.com",
"localhost",
"127.0.0.1",
"::1"
];

resolveNoProxy 将 defaults 无条件排在首位:

all: [...defaults, ...envSystem, ...envReasonix, ...extra]

SelectiveProxyDispatcher.dispatch() 发现 api.deepseek.com 匹配 defaults → 路由到 undici Agent() 直连:

const target = host && matchesNoProxy(host, this.patterns) ? this.direct : this.proxied;

但公司防火墙封锁直连外网,undici Agent 直连 api.deepseek.com:443 超时(ConnectTimeoutError),导致 getBalance() 返回 null。

而 curl 能正常工作,是因为 curl 只读取环境变量中的 NO_PROXY,其中 不包含 api.deepseek.com,所以 curl 正确走了代理。

攻击链

DEFAULT_NO_PROXY 强制包含 api.deepseek.com
→ SelectiveProxyDispatcher 将请求路由到 undici Agent 直连
→ 企业防火墙封锁直连 → ConnectTimeoutError
→ getBalance() 返回 null → doctor 报告 api reach 失败

建议修复

  1. DEFAULT_NO_PROXY 只保留本地地址,移除 api.deepseek.com 和 *.deepseek.com:

var DEFAULT_NO_PROXY = [

  • "api.deepseek.com",
  • "*.deepseek.com",
    "localhost",
    "127.0.0.1",
    "::1"
    ];
  1. 或者:提供 config.json 配置项允许用户覆盖/清空默认 NO_PROXY 列表,而不是无条件 prepend defaults。

其他信息

--no-proxy 标志同样无法解决此问题,因为它只是跳过了 installProxyIfConfigured,而 Node.js 内置 fetch 也不会自动使用
https_proxy 环境变量。

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions