实现双授权系统:支持FACTORY_API_KEY环境变量优先级和客户端授权回退机制

- 新增FACTORY_API_KEY环境变量支持(最高优先级)
- 保留现有refresh token自动刷新机制
- 添加客户端authorization头作为fallback
- 优化启动流程,无认证配置时不报错退出
- 更新所有端点支持新的授权优先级系统
- 修改GPT-5-Codex推理级别为off
This commit is contained in:
1e0n
2025-10-08 19:42:39 +08:00
parent 2dc8c89270
commit 25f89a12b7
4 changed files with 72 additions and 50 deletions

View File

@@ -66,7 +66,7 @@ async function handleChatCompletions(req, res) {
// Get API key (will auto-refresh if needed)
let authHeader;
try {
authHeader = await getApiKey();
authHeader = await getApiKey(req.headers.authorization);
} catch (error) {
logError('Failed to get API key', error);
return res.status(500).json({
@@ -209,7 +209,7 @@ async function handleDirectResponses(req, res) {
// Get API key
let authHeader;
try {
authHeader = await getApiKey();
authHeader = await getApiKey(req.headers.authorization);
} catch (error) {
logError('Failed to get API key', error);
return res.status(500).json({
@@ -338,7 +338,7 @@ async function handleDirectMessages(req, res) {
// Get API key
let authHeader;
try {
authHeader = await getApiKey();
authHeader = await getApiKey(req.headers.authorization);
} catch (error) {
logError('Failed to get API key', error);
return res.status(500).json({