浏览代码

Return 404 for non html files

Rodrigo Agundez 2 月之前
父节点
当前提交
5d68737b31
共有 1 个文件被更改,包括 7 次插入1 次删除
  1. 7 1
      backend/open_webui/main.py

+ 7 - 1
backend/open_webui/main.py

@@ -330,7 +330,13 @@ class SPAStaticFiles(StaticFiles):
             return await super().get_response(path, scope)
             return await super().get_response(path, scope)
         except (HTTPException, StarletteHTTPException) as ex:
         except (HTTPException, StarletteHTTPException) as ex:
             if ex.status_code == 404:
             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:
             else:
                 raise ex
                 raise ex