DeepTutor: Lifelong Personalized Tutoring. https://deeptutor.info/.
Python ai-agentsai-tutorclawbotcli-tooldeepresearchinteractive-learninglearningmulti-agent-systemsrag
fix: knowledge base listing through proxy
dxhome2fb4d8977154
diff --git a/.gitignore b/.gitignoreindex 5a8fee249..b1ee47df4 100644--- a/.gitignore+++ b/.gitignore@@ -76,6 +76,9 @@ venv.bak/# Node modules# No trailing slash: also ignore symlinked installs borrowed by worktrees.node_modules+# pnpm metadata generated locally; this project tracks package-lock.json instead.+web/pnpm-lock.yaml+web/pnpm-workspace.yaml# Next.js build output.next/diff --git a/deeptutor/api/routers/knowledge.py b/deeptutor/api/routers/knowledge.pyindex 6915f01da..1a61ee888 100644--- a/deeptutor/api/routers/knowledge.py+++ b/deeptutor/api/routers/knowledge.py@@ -2800,6 +2800,21 @@ async def list_knowledge_bases():raise HTTPException(status_code=500, detail=f"Failed to list knowledge bases: {e!s}")+ "/knowledge-bases/list",+ response_model=list[KnowledgeBaseInfo],+ include_in_schema=False,+)+async def list_knowledge_bases_proxy_alias():+ """Proxy-safe alias for the KB list.++ The collection URL is reserved by the frontend's streaming multipart+ create route, which bypasses Next's request-buffering proxy. Browser list+ requests use this path so GET traffic can use the normal backend rewrite.+ """+ return await list_knowledge_bases()++@router.get("/knowledge-bases/{kb_name}")async def get_knowledge_base_details(kb_name: str):"""Get detailed info for a specific KB."""diff --git a/tests/api/test_knowledge_router.py b/tests/api/test_knowledge_router.pyindex 14977e421..fd518cf07 100644--- a/tests/api/test_knowledge_router.py+++ b/tests/api/test_knowledge_router.py@@ -57,6 +57,11 @@ def _build_app() -> FastAPI:("path", "route_path", "surface"),[("/api/knowledge-bases", "/api/knowledge-bases", "reading"),+ (+ "/api/knowledge-bases/list",+ "/api/knowledge-bases/list",+ "reading",+ ),("/api/knowledge-bases/demo", "/api/knowledge-bases/{kb_name}", "reading"),("/api/knowledge-bases/demo/files", "/api/knowledge-bases/{kb_name}/files", "reading"),(diff --git a/web/features/knowledge/api/client.ts b/web/features/knowledge/api/client.tsindex d07a4c8ca..d5df79398 100644--- a/web/features/knowledge/api/client.ts+++ b/web/features/knowledge/api/client.ts@@ -293,8 +293,8 @@ export async function listKnowledgeBases(options?: {const response = await apiFetch(apiUrl(options?.library- ? "/api/knowledge-bases?resource_library=true"- : "/api/knowledge-bases",+ ? "/api/knowledge-bases/list?resource_library=true"+ : "/api/knowledge-bases/list",),{cache: "no-store",diff --git a/web/proxy.ts b/web/proxy.tsindex 43fd12925..a81570b6f 100644--- a/web/proxy.ts+++ b/web/proxy.ts@@ -94,10 +94,11 @@ export function proxy(req: NextRequest): NextResponse {export const config = {// Run on every request except Next.js internals and the favicon. The /api/*// and /ws/* paths are explicitly handled above (rewritten to the backend);- // large knowledge create/upload requests are handled by dedicated App Router- // endpoints that stream directly to FastAPI. The collection handler also- // forwards GET because a route module owns every method at that pathname.- // Excluding these endpoints here is crucial:+ // Knowledge-base creation and upload requests that carry multipart bodies+ // are handled by dedicated App Router endpoints that stream directly to+ // FastAPI. The browser's list call uses /api/knowledge-bases/list so it can+ // pass through the normal backend rewrite below. Excluding multipart routes+ // here is crucial:// merely entering Proxy makes Next clone and cap the multipart body.// the browser's /_next/image optimizer requests are excluded here, while the// optimizer's loopback fetch for the source image (e.g. /logo.png) is letdiff --git a/web/tests/proxy-policy.test.ts b/web/tests/proxy-policy.test.tsindex 6b80474a6..b5f1f46df 100644--- a/web/tests/proxy-policy.test.ts+++ b/web/tests/proxy-policy.test.ts@@ -45,6 +45,7 @@ test("large knowledge uploads bypass the buffering proxy", () => {unstable_doesMiddlewareMatch({ config: proxyConfig, url });assert.equal(matches("http://localhost/api/knowledge-bases"), false);+ assert.equal(matches("http://localhost/api/knowledge-bases/list"), true);assert.equal(matches("http://localhost/api/knowledge-bases/my%20kb/upload"),false,