diff --git a/src/basic_memory/api/app.py b/src/basic_memory/api/app.py index 04c2e40e2..c548e9e4c 100644 --- a/src/basic_memory/api/app.py +++ b/src/basic_memory/api/app.py @@ -92,17 +92,7 @@ async def _file_sync_runner() -> None: lifespan=lifespan, ) -# Include v1 routers -app.include_router(knowledge.router, prefix="/{project}") -app.include_router(memory.router, prefix="/{project}") -app.include_router(resource.router, prefix="/{project}") -app.include_router(search.router, prefix="/{project}") -app.include_router(project.project_router, prefix="/{project}") -app.include_router(directory_router.router, prefix="/{project}") -app.include_router(prompt_router.router, prefix="/{project}") -app.include_router(importer_router.router, prefix="/{project}") - -# Include v2 routers (ID-based paths) +# Include v2 routers FIRST (more specific paths must match before /{project} catch-all) app.include_router(v2_knowledge, prefix="/v2/projects/{project_id}") app.include_router(v2_memory, prefix="/v2/projects/{project_id}") app.include_router(v2_search, prefix="/v2/projects/{project_id}") @@ -112,6 +102,16 @@ async def _file_sync_runner() -> None: app.include_router(v2_importer, prefix="/v2/projects/{project_id}") app.include_router(v2_project, prefix="/v2") +# Include v1 routers (/{project} is a catch-all, must come after specific prefixes) +app.include_router(knowledge.router, prefix="/{project}") +app.include_router(memory.router, prefix="/{project}") +app.include_router(resource.router, prefix="/{project}") +app.include_router(search.router, prefix="/{project}") +app.include_router(project.project_router, prefix="/{project}") +app.include_router(directory_router.router, prefix="/{project}") +app.include_router(prompt_router.router, prefix="/{project}") +app.include_router(importer_router.router, prefix="/{project}") + # Project resource router works across projects app.include_router(project.project_resource_router) app.include_router(management.router)