Skip to content

Commit 611fe0c

Browse files
committed
refac
1 parent 31406ca commit 611fe0c

1 file changed

Lines changed: 6 additions & 7 deletions

File tree

backend/open_webui/main.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff 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)

0 commit comments

Comments
 (0)