mirror of
https://github.com/Wei-Shaw/claude-relay-service.git
synced 2026-01-23 09:38:02 +00:00
fix: 修复openai账号代理问题
This commit is contained in:
@@ -6076,6 +6076,7 @@ router.post('/openai-accounts/exchange-code', authenticateAdmin, async (req, res
|
|||||||
const proxyAgent = ProxyHelper.createProxyAgent(sessionData.proxy)
|
const proxyAgent = ProxyHelper.createProxyAgent(sessionData.proxy)
|
||||||
if (proxyAgent) {
|
if (proxyAgent) {
|
||||||
axiosConfig.httpsAgent = proxyAgent
|
axiosConfig.httpsAgent = proxyAgent
|
||||||
|
axiosConfig.proxy = false
|
||||||
}
|
}
|
||||||
|
|
||||||
// 交换 authorization code 获取 tokens
|
// 交换 authorization code 获取 tokens
|
||||||
|
|||||||
@@ -226,6 +226,7 @@ const handleResponses = async (req, res) => {
|
|||||||
// 如果有代理,添加代理配置
|
// 如果有代理,添加代理配置
|
||||||
if (proxyAgent) {
|
if (proxyAgent) {
|
||||||
axiosConfig.httpsAgent = proxyAgent
|
axiosConfig.httpsAgent = proxyAgent
|
||||||
|
axiosConfig.proxy = false
|
||||||
logger.info(`🌐 Using proxy for OpenAI request: ${ProxyHelper.getProxyDescription(proxy)}`)
|
logger.info(`🌐 Using proxy for OpenAI request: ${ProxyHelper.getProxyDescription(proxy)}`)
|
||||||
} else {
|
} else {
|
||||||
logger.debug('🌐 No proxy configured for OpenAI request')
|
logger.debug('🌐 No proxy configured for OpenAI request')
|
||||||
|
|||||||
@@ -145,7 +145,7 @@ async function refreshAccessToken(refreshToken, proxy = null) {
|
|||||||
const proxyAgent = ProxyHelper.createProxyAgent(proxy)
|
const proxyAgent = ProxyHelper.createProxyAgent(proxy)
|
||||||
if (proxyAgent) {
|
if (proxyAgent) {
|
||||||
requestOptions.httpsAgent = proxyAgent
|
requestOptions.httpsAgent = proxyAgent
|
||||||
requestOptions.proxy = false // 重要:禁用 axios 的默认代理,强制使用我们的 httpsAgent
|
requestOptions.proxy = false
|
||||||
logger.info(
|
logger.info(
|
||||||
`🌐 Using proxy for OpenAI token refresh: ${ProxyHelper.getProxyDescription(proxy)}`
|
`🌐 Using proxy for OpenAI token refresh: ${ProxyHelper.getProxyDescription(proxy)}`
|
||||||
)
|
)
|
||||||
@@ -671,7 +671,10 @@ async function getAllAccounts() {
|
|||||||
if (accountData.proxy) {
|
if (accountData.proxy) {
|
||||||
try {
|
try {
|
||||||
accountData.proxy = JSON.parse(accountData.proxy)
|
accountData.proxy = JSON.parse(accountData.proxy)
|
||||||
// 不屏蔽代理密码,返回明文
|
// 屏蔽代理密码
|
||||||
|
if (accountData.proxy && accountData.proxy.password) {
|
||||||
|
accountData.proxy.password = '******'
|
||||||
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
// 如果解析失败,设置为null
|
// 如果解析失败,设置为null
|
||||||
accountData.proxy = null
|
accountData.proxy = null
|
||||||
|
|||||||
Reference in New Issue
Block a user