diff --git a/backend/internal/repository/http_upstream.go b/backend/internal/repository/http_upstream.go index 9daf80be..d72d4006 100644 --- a/backend/internal/repository/http_upstream.go +++ b/backend/internal/repository/http_upstream.go @@ -175,10 +175,10 @@ func (s *httpUpstreamService) DoWithTLS(req *http.Request, proxyURL string, acco return s.Do(req, proxyURL, accountID, accountConcurrency) } - // 优先使用 Node.js TLS 代理模式(仅 Anthropic API) - // 其他上游(Sora/Bedrock 等)需要 Chrome 指纹,走原有 uTLS 路径 - if s.isNodeTLSProxyEnabled() && req != nil && req.URL != nil && req.URL.Hostname() == "api.anthropic.com" { - return s.doViaNodeTLSProxy(req, accountID, accountConcurrency) + // 优先使用 Node.js TLS 代理模式(仅 Anthropic API 且无 per-account 代理) + // 如果账号配置了独立代理,走原有 uTLS 路径(保持代理 IP 不变) + if s.isNodeTLSProxyEnabled() && proxyURL == "" && req != nil && req.URL != nil && req.URL.Hostname() == "api.anthropic.com" { + return s.doViaNodeTLSProxy(req, proxyURL, accountID, accountConcurrency) } // TLS 指纹已启用,记录调试日志 @@ -273,7 +273,7 @@ func (s *httpUpstreamService) shouldRouteViaNodeProxy(req *http.Request) bool { // 由 Node.js 进程使用原生 TLS 栈完成到上游的 HTTPS 连接。 // 原始目标主机通过 X-Forwarded-Host 传递给 Node.js 代理, // 代理据此动态连接到正确的上游主机。 -func (s *httpUpstreamService) doViaNodeTLSProxy(req *http.Request, accountID int64, accountConcurrency int) (*http.Response, error) { +func (s *httpUpstreamService) doViaNodeTLSProxy(req *http.Request, proxyURL string, accountID int64, accountConcurrency int) (*http.Response, error) { proxyCfg := s.cfg.Gateway.NodeTLSProxy listenHost := proxyCfg.ListenHost if listenHost == "" {