fix: proxy only Anthropic via VPS; sechenov direct (VPS was banned)

This commit is contained in:
aedes
2026-04-21 17:18:48 +03:00
parent 56371822dc
commit 720469dfc8

View File

@@ -2,13 +2,11 @@ const express = require('express');
const path = require('path'); const path = require('path');
const fs = require('fs'); const fs = require('fs');
const os = require('os'); const os = require('os');
const { ProxyAgent, setGlobalDispatcher } = require('undici'); const { ProxyAgent } = require('undici');
const proxyUrl = process.env.HTTPS_PROXY || process.env.HTTP_PROXY; const proxyUrl = process.env.HTTPS_PROXY || process.env.HTTP_PROXY;
if (proxyUrl) { const anthropicAgent = proxyUrl ? new ProxyAgent(proxyUrl) : undefined;
setGlobalDispatcher(new ProxyAgent(proxyUrl)); if (proxyUrl) console.log(`✓ Anthropic proxy: ${proxyUrl} (sechenov: direct)`);
console.log(`✓ Using proxy: ${proxyUrl}`);
}
const app = express(); const app = express();
const PUBLIC_DIR = path.join(__dirname, 'public'); const PUBLIC_DIR = path.join(__dirname, 'public');
@@ -57,6 +55,7 @@ const SYSTEM_PROMPT = [
async function callClaude(modelId, text, accessToken) { async function callClaude(modelId, text, accessToken) {
return fetch('https://api.anthropic.com/v1/messages', { return fetch('https://api.anthropic.com/v1/messages', {
method: 'POST', method: 'POST',
dispatcher: anthropicAgent,
headers: { headers: {
'Content-Type': 'application/json', 'Content-Type': 'application/json',
'Authorization': `Bearer ${accessToken}`, 'Authorization': `Bearer ${accessToken}`,