File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1424,15 +1424,14 @@ async def check_url(request: Request, call_next):
14241424
14251425 request .state .token = HTTPAuthorizationCredentials (scheme = 'Bearer' , credentials = request .cookies .get ('token' ))
14261426
1427- # Fallback to x-api-key header for Anthropic Messages API routes
1427+ # Fallback to x-api-key header (Anthropic-compatible clients use this
1428+ # for ALL requests, including GET /v1/models, not just POST /v1/messages).
14281429 if request .state .token is None and request .headers .get ('x-api-key' ):
1429- request_path = request .url .path
1430- if request_path in ('/api/message' , '/api/v1/messages' ) or request_path .startswith ('/ollama/v1/messages' ):
1431- from fastapi .security import HTTPAuthorizationCredentials
1430+ from fastapi .security import HTTPAuthorizationCredentials
14321431
1433- request .state .token = HTTPAuthorizationCredentials (
1434- scheme = 'Bearer' , credentials = request .headers .get ('x-api-key' )
1435- )
1432+ request .state .token = HTTPAuthorizationCredentials (
1433+ scheme = 'Bearer' , credentials = request .headers .get ('x-api-key' )
1434+ )
14361435
14371436 request .state .enable_api_keys = app .state .config .ENABLE_API_KEYS
14381437 response = await call_next (request )
You can’t perform that action at this time.
0 commit comments