Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions src/utils/header-profile.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@
const config = require('../config/index.js')
const { getTimezoneHeader } = require('./tools')

// chat.qwen.ai 前端版本(FE version):请求头 Version 必须与线上前端一致,
// 否则 /api/v2/chat/completions 返回 Bad_Request(2026-10-17 实测线上为 0.3.19)。
// 前端三天内从 0.3.17 升到 0.3.19,此处过期需同步更新。
const QWEN_WEB_VERSION = '0.3.19'

// Chrome version pool — small set to avoid identical UA across all accounts
const CHROME_VERSIONS = ['149.0.0.0', '148.0.0.0', '147.0.0.0', '146.0.0.0']

Expand Down Expand Up @@ -99,7 +104,7 @@ function buildRequestHeaders(account, options = {}) {
'accept': options.accept || 'application/json',
'accept-encoding': 'gzip, deflate, br, zstd',
'source': 'web',
'version': '0.2.81',
'Version': QWEN_WEB_VERSION,
'timezone': getTimezoneHeader(),
'connection': 'keep-alive',
'sec-fetch-dest': 'empty',
Expand All @@ -116,6 +121,8 @@ function buildRequestHeaders(account, options = {}) {
if (options.ssxmodItna) cookieParts.push(`ssxmod_itna=${options.ssxmodItna}`)
if (options.ssxmodItna2) cookieParts.push(`ssxmod_itna2=${options.ssxmodItna2}`)
headers['cookie'] = cookieParts.join(';')
// FE 0.3.x 起 completions 硬校验 Bearer 鉴权(缺失则 Unauthorized),与前端 eX 拦截器一致
headers['Authorization'] = `Bearer ${options.token}`
}
if (options.extra) Object.assign(headers, options.extra)
return headers
Expand Down Expand Up @@ -144,7 +151,7 @@ function buildRequestHeaders(account, options = {}) {
'accept': options.accept || 'application/json',
'accept-encoding': 'gzip, deflate, br, zstd',
'source': 'web',
'version': '0.2.81',
'Version': QWEN_WEB_VERSION,
'timezone': timezone,
'connection': 'keep-alive',
'sec-fetch-dest': 'empty',
Expand All @@ -163,6 +170,8 @@ function buildRequestHeaders(account, options = {}) {
if (options.ssxmodItna) cookieParts.push(`ssxmod_itna=${options.ssxmodItna}`)
if (options.ssxmodItna2) cookieParts.push(`ssxmod_itna2=${options.ssxmodItna2}`)
headers['cookie'] = cookieParts.join(';')
// FE 0.3.x 起 completions 硬校验 Bearer 鉴权(缺失则 Unauthorized),与前端 eX 拦截器一致
headers['Authorization'] = `Bearer ${options.token}`
}

if (options.extra) Object.assign(headers, options.extra)
Expand Down
6 changes: 3 additions & 3 deletions src/utils/request.js
Original file line number Diff line number Diff line change
Expand Up @@ -728,7 +728,7 @@ const postChatRequest = async (body, options, currentAccount, currentToken, brea
}
})

// 构建请求配置(与通义千问 React Web 客户端完全一致,对齐 FE 0.2.81)
// 构建请求配置(与通义千问 React Web 客户端完全一致,对齐 FE 0.3.19)
const requestConfig = {
headers,
responseType: 'stream', // Always use streaming (upstream doesn't support stream=false)
Expand All @@ -749,7 +749,7 @@ const postChatRequest = async (body, options, currentAccount, currentToken, brea
// 浏览器 referer 为 /c/<chat_id>(在 chat_id 生成后动态设置)
requestConfig.headers.referer = `${chatBaseUrl}/c/${chat_id}`
const url = `${chatBaseUrl}/api/v2/chat/completions?chat_id=` + chat_id
// 对齐网页双写 chatId/parentId(FE 0.2.81)
// 对齐网页双写 chatId/parentId(FE 0.3.19)
const parentId = options.parentId ?? body.parentId ?? body.parent_id ?? null
const messages = Array.isArray(body.messages)
? body.messages.map(message => ({
Expand Down Expand Up @@ -906,7 +906,7 @@ const generateChatID = async (currentToken, model, account, chatType = 't2t') =>

applyProxyToAxiosConfig(requestConfig, account);

// 对齐 chat.qwen.ai FE 0.2.81:chatId/project_id + normal 模式
// 对齐 chat.qwen.ai FE 0.3.19:chatId/project_id + normal 模式
const response_data = await axios.post(`${chatBaseUrl}/api/v2/chats/new`, {
chatId: '',
models: [model],
Expand Down