[Frontend] Simplify AuthenticationMiddleware path extraction (#43426)

Signed-off-by: Russell Bryant <rbryant@redhat.com>
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Russell Bryant
2026-05-22 11:59:14 -07:00
committed by GitHub
co-authored by Claude Opus 4.6
parent 843715739b
commit 2b94d1c0ca
+2 -2
View File
@@ -15,7 +15,7 @@ from fastapi import FastAPI, HTTPException, Request
from fastapi.exceptions import RequestValidationError from fastapi.exceptions import RequestValidationError
from fastapi.responses import JSONResponse from fastapi.responses import JSONResponse
from starlette.concurrency import iterate_in_threadpool from starlette.concurrency import iterate_in_threadpool
from starlette.datastructures import URL, Headers, MutableHeaders from starlette.datastructures import Headers, MutableHeaders
from starlette.types import ASGIApp, Message, Receive, Scope, Send from starlette.types import ASGIApp, Message, Receive, Scope, Send
from vllm import envs from vllm import envs
@@ -80,7 +80,7 @@ class AuthenticationMiddleware:
# in which case we don't need to do anything # in which case we don't need to do anything
return self.app(scope, receive, send) return self.app(scope, receive, send)
root_path = scope.get("root_path", "") root_path = scope.get("root_path", "")
url_path = URL(scope=scope).path.removeprefix(root_path) url_path = scope["path"].removeprefix(root_path)
headers = Headers(scope=scope) headers = Headers(scope=scope)
# Type narrow to satisfy mypy. # Type narrow to satisfy mypy.
if url_path.startswith(GUARDED_PREFIX) and not self.verify_token(headers): if url_path.startswith(GUARDED_PREFIX) and not self.verify_token(headers):