diff --git a/tools/server/server-http.cpp b/tools/server/server-http.cpp index f52240b106..be2af26223 100644 --- a/tools/server/server-http.cpp +++ b/tools/server/server-http.cpp @@ -143,7 +143,11 @@ bool server_http_context::init(const common_params & params) { "/v1/health", "/models", "/v1/models", - "/api/tags" + "/api/tags", + "/", + "/index.html", + "/bundle.js", + "/bundle.css", }; // If API key is not set, skip validation @@ -151,8 +155,8 @@ bool server_http_context::init(const common_params & params) { return true; } - // If path is public or is static file, skip validation - if (public_endpoints.find(req.path) != public_endpoints.end() || req.path == "/") { + // If path is public or static file, skip validation + if (public_endpoints.find(req.path) != public_endpoints.end()) { return true; } diff --git a/tools/server/tests/unit/test_security.py b/tools/server/tests/unit/test_security.py index 8c38b89d53..bb22095f12 100644 --- a/tools/server/tests/unit/test_security.py +++ b/tools/server/tests/unit/test_security.py @@ -22,6 +22,15 @@ def test_access_public_endpoint(endpoint: str): assert "error" not in res.body +def test_access_static_assets_without_api_key(): + """Static web UI assets should not require API key authentication (issue #21229)""" + global server + server.start() + for path in ["/", "/bundle.js", "/bundle.css"]: + res = server.make_request("GET", path) + assert res.status_code == 200, f"Expected 200 for {path}, got {res.status_code}" + + @pytest.mark.parametrize("api_key", [None, "invalid-key"]) def test_incorrect_api_key(api_key: str): global server