diff --git a/server.js b/server.js index 5ba2808..8037e82 100644 --- a/server.js +++ b/server.js @@ -2,10 +2,13 @@ const express = require('express'); const path = require('path'); const fs = require('fs'); const os = require('os'); -const { ProxyAgent } = require('undici'); +const { ProxyAgent, Agent, setGlobalDispatcher } = require('undici'); const proxyUrl = process.env.HTTPS_PROXY || process.env.HTTP_PROXY; -const anthropicAgent = proxyUrl ? new ProxyAgent(proxyUrl) : undefined; +const directAgent = new Agent(); +const anthropicAgent = proxyUrl ? new ProxyAgent(proxyUrl) : directAgent; +// Force global default = DIRECT. Anthropic calls override with their own dispatcher. +setGlobalDispatcher(directAgent); if (proxyUrl) console.log(`✓ Anthropic proxy: ${proxyUrl} (sechenov: direct)`); const app = express();