From 5d68737b31c18306595ac85d399c9d79436599ab Mon Sep 17 00:00:00 2001 From: Rodrigo Agundez Date: Tue, 11 Feb 2025 18:49:36 +0800 Subject: [PATCH 1/2] Return 404 for non html files --- backend/open_webui/main.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/backend/open_webui/main.py b/backend/open_webui/main.py index 2b741a2bc..2086b50ee 100644 --- a/backend/open_webui/main.py +++ b/backend/open_webui/main.py @@ -330,7 +330,13 @@ class SPAStaticFiles(StaticFiles): return await super().get_response(path, scope) except (HTTPException, StarletteHTTPException) as ex: if ex.status_code == 404: - return await super().get_response("index.html", scope) + if path.endswith(".html"): + response = await super().get_response("index.html", scope) + response.status_code = 200 + return response + else: + # Return 404 for non-HTML files + raise ex else: raise ex From 31ee7a68a2ae3f3b9b039523c4f017399df98c28 Mon Sep 17 00:00:00 2001 From: Rodrigo Agundez Date: Tue, 11 Feb 2025 21:21:27 +0800 Subject: [PATCH 2/2] Only javascript files --- backend/open_webui/main.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/backend/open_webui/main.py b/backend/open_webui/main.py index 2086b50ee..9acd961da 100644 --- a/backend/open_webui/main.py +++ b/backend/open_webui/main.py @@ -330,13 +330,11 @@ class SPAStaticFiles(StaticFiles): return await super().get_response(path, scope) except (HTTPException, StarletteHTTPException) as ex: if ex.status_code == 404: - if path.endswith(".html"): - response = await super().get_response("index.html", scope) - response.status_code = 200 - return response - else: - # Return 404 for non-HTML files + if path.endswith(".js"): + # Return 404 for javascript files raise ex + else: + return await super().get_response("index.html", scope) else: raise ex