From 0739b1947f4081b0edafc7951134a928e39302e7 Mon Sep 17 00:00:00 2001 From: A-Mahla <89754740+A-Mahla@users.noreply.github.com> Date: Tue, 2 Apr 2024 10:20:28 +0200 Subject: [PATCH] [Frontend][Bugfix] allow using the default middleware with a root path (#3788) Co-authored-by: A-Mahla <> --- vllm/entrypoints/openai/api_server.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/vllm/entrypoints/openai/api_server.py b/vllm/entrypoints/openai/api_server.py index e550943c..32282bfd 100644 --- a/vllm/entrypoints/openai/api_server.py +++ b/vllm/entrypoints/openai/api_server.py @@ -127,7 +127,8 @@ if __name__ == "__main__": @app.middleware("http") async def authentication(request: Request, call_next): - if not request.url.path.startswith("/v1"): + root_path = "" if args.root_path is None else args.root_path + if not request.url.path.startswith(f"{root_path}/v1"): return await call_next(request) if request.headers.get("Authorization") != "Bearer " + token: return JSONResponse(content={"error": "Unauthorized"},