Alma 配置的代理在测试连接时正常,但实际的 API 请求没有走代理,导致被墙 API 返回 403 错误。
在 Alma 设置 → 网络 中配置代理:
类型:socks5 或 http
主机:127.0.0.1
端口:10808 (socks5) 或 7890 (http)
启用代理:是
测试代理连接: 成功
POST /api/settings/test-proxy → ok: true 从 Claude Subscription 获取模型列表: 失败 (403)
POST /api/providers/claude-subscription/models/fetch → 403 Forbidden 开启 Clash TUN 模式(系统级全局代理): 成功
不需要在 Alma 配置代理即可正常工作
所有 HTTP/HTTPS 请求(特别是 api.anthropic.com 的 API 调用)都应该使用配置的代理。
测试代理接口:正确使用代理
获取模型/实际 API 调用:绕过代理,直连服务器
系统:Windows
Alma 版本:最新版
代理类型:SOCKS5 / HTTP(两种都测试过)
代理软件:Clash Verge
代理配置应用不一致导致的问题:
javascript
// 这个代码路径正常工作(测试接口) const proxyAgent = createProxyAgent(config); fetch(url, { agent: proxyAgent }); // 这个代码路径不工作(实际 API 调用) fetch(url); // 缺少 agent 参数! Electron/Node.js 的坑:原生 fetch() 不会自动使用代理设置,必须显式传递 proxy agent 到每个请求。
确保所有 HTTP 客户端都使用配置的代理:
javascript
// 从设置创建 proxy agent function getProxyAgent() { const proxy = settings.network.proxy; if (!proxy.enabled) return undefined; const { ProxyAgent } = require('undici'); const proxyUrl = `${proxy.type}://${proxy.host}:${proxy.port}`; return new ProxyAgent(proxyUrl); } // 应用到所有 fetch 调用 const agent = getProxyAgent(); fetch('https://api.anthropic.com/v1/models', { agent, dispatcher: agent // undici 需要 }); 或者使用 axios:
javascript
const { SocksProxyAgent } = require('socks-proxy-agent'); axios.get(url, { httpsAgent: new SocksProxyAgent('socks5://127.0.0.1:10808'), httpAgent: new SocksProxyAgent('socks5://127.0.0.1:10808') }); 在代理软件(如 Clash)中开启 TUN 模式,强制系统级流量路由
Please authenticate to join the conversation.
In Review
Feature Request
22 days ago

nlospc
Get notified by email when there are changes.
In Review
Feature Request
22 days ago

nlospc
Get notified by email when there are changes.