支持Anthropic端点客户端x-api-key:\n- /v1/messages读取x-api-key并优先作为客户端授权传递\n- getAnthropicHeaders转发x-api-key并透传anthropic-version\n- CORS允许X-API-Key与anthropic-version
This commit is contained in:
@@ -257,10 +257,13 @@ async function handleDirectResponses(req, res) {
|
||||
|
||||
logInfo(`Direct forwarding to ${model.type} endpoint: ${endpoint.base_url}`);
|
||||
|
||||
// Get API key
|
||||
// Get API key - support client x-api-key for anthropic endpoint
|
||||
let authHeader;
|
||||
try {
|
||||
authHeader = await getApiKey(req.headers.authorization);
|
||||
const clientAuthFromXApiKey = req.headers['x-api-key']
|
||||
? `Bearer ${req.headers['x-api-key']}`
|
||||
: null;
|
||||
authHeader = await getApiKey(req.headers.authorization || clientAuthFromXApiKey);
|
||||
} catch (error) {
|
||||
logError('Failed to get API key', error);
|
||||
return res.status(500).json({
|
||||
|
||||
Reference in New Issue
Block a user