From f216bfab63042d895ec440346c118840bca78f54 Mon Sep 17 00:00:00 2001 From: Classic298 <27028174+Classic298@users.noreply.github.com> Date: Tue, 19 May 2026 18:50:07 +0200 Subject: [PATCH] refactor: remove unused POST /api/v1/utils/markdown endpoint (#24779) POST /utils/markdown rendered a markdown string to HTML server-side. Its only frontend wrapper, getHTMLFromMarkdown in src/lib/apis/utils/index.ts, is dead: nothing imports or calls it, the route is hit by no other code path, and the path string appears nowhere else in the repo (no direct fetch, no test, no docs). Markdown is rendered client-side in the UI, so this endpoint was redundant. Fully self-contained removal: the endpoint, its MarkdownForm model, the now-orphaned 'import markdown' in the utils router (used only here), and the dead getHTMLFromMarkdown wrapper. Nothing else depends on any of them. Co-authored-by: Claude Opus 4.7 (1M context) --- backend/open_webui/routers/utils.py | 10 ---------- src/lib/apis/utils/index.ts | 26 -------------------------- 2 files changed, 36 deletions(-) diff --git a/backend/open_webui/routers/utils.py b/backend/open_webui/routers/utils.py index 92caf5fee9..04047fd47b 100644 --- a/backend/open_webui/routers/utils.py +++ b/backend/open_webui/routers/utils.py @@ -3,7 +3,6 @@ from __future__ import annotations import logging import black -import markdown from fastapi import APIRouter, Depends, HTTPException, Request, Response, status from open_webui.config import DATA_DIR, ENABLE_ADMIN_EXPORT from open_webui.constants import ERROR_MESSAGES @@ -73,15 +72,6 @@ async def execute_code(request: Request, form_data: CodeForm, user=Depends(get_v ) -class MarkdownForm(BaseModel): - md: str - - -@router.post('/markdown') -async def get_html_from_markdown(form_data: MarkdownForm, user=Depends(get_verified_user)): - return {'html': markdown.markdown(form_data.md)} - - class ChatForm(BaseModel): title: str messages: list[dict] diff --git a/src/lib/apis/utils/index.ts b/src/lib/apis/utils/index.ts index e5fea091eb..f38f10ae0b 100644 --- a/src/lib/apis/utils/index.ts +++ b/src/lib/apis/utils/index.ts @@ -122,32 +122,6 @@ export const downloadChatAsPDF = async (token: string, title: string, messages: return blob; }; -export const getHTMLFromMarkdown = async (token: string, md: string) => { - let error = null; - - const res = await fetch(`${WEBUI_API_BASE_URL}/utils/markdown`, { - method: 'POST', - headers: { - 'Content-Type': 'application/json', - Authorization: `Bearer ${token}` - }, - body: JSON.stringify({ - md: md - }) - }) - .then(async (res) => { - if (!res.ok) throw await res.json(); - return res.json(); - }) - .catch((err) => { - console.error(err); - error = err; - return null; - }); - - return res.html; -}; - export const downloadDatabase = async (token: string) => { let error = null;