fix(api): 加 editor/drafts、editor/clips/from-assets、api/health 路径别名,修复前端 404 导致的 10s 超时 #2033
Reference in New Issue
Block a user
Delete Branch "fix/editor-route-aliases-2033"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
背景
前端智能剪辑流程报 2 个 10s 超时错误:
[useDraftAutoSave] 自动保存草稿 timeout 10s[useStep2Materials] 智能选片 timeout 10s排查发现不是 API 性能问题(health 100ms、连接池/队列正常),是前端请求路径和后端路由不匹配,全部 404:
GET/PUT /api/v1/editor/drafts/api/v1/templates/{template_id}/editor/draft(单数+要 template_id)POST /api/v1/editor/clips/from-assets/api/v1/clips/from-assets(无 editor 前缀)或/api/v1/templates/{template_id}/editor/clips/from-assets(要 template_id)GET /api/health(前端探针)/health(根路径)staging DB 当前为空库(昨天 alembic 重建),需要测试用户重新注册上传素材,ingest pipeline 会自动跑场景切分和标签。
修改
新增
apps/api/app/api/routes/drafts_standalone.py:参照已有clips_standalone.py模式,提供无template_id路径参数的GET/PUT /drafts别名端点,template_id 缺省时通过_default_template.get_or_create_default_template_id兜底到用户默认模板,内部复用templates_editor/draft.py的get_editor_draft/update_editor_draft核心逻辑。修改
apps/api/app/api/router.py:editor_legacy_router(prefix=/editor),同时挂载clips_standalone_router和drafts_standalone_router,一次性覆盖:POST /api/v1/editor/clips/from-assetsGET /api/v1/editor/drafts/PUT /api/v1/editor/draftsapi_health_router(prefix=/api)挂载 health_check_router,提供/api/health、/api/ready、/api/startup别名。/api/v1/templates/{template_id}/editor/*和/api/v1/clips/from-assets、/health保持不变,向后兼容。兼容性
验证
CI 通过后部署到 staging,预期:
GET/PUT /api/v1/editor/drafts返回 200(template_id 缺省时自动兜底默认模板)POST /api/v1/editor/clips/from-assets返回 200/正常业务响应GET /api/health返回 200GET /health、GET /api/v1/clips/from-assets、GET /api/v1/templates/{tid}/editor/draft等旧路径继续正常根因:前端 useDraftAutoSave 调 /api/v1/editor/drafts(复数、无 template_id), 后端只有 /api/v1/templates/{template_id}/editor/draft(单数、要路径参数),导致 404 并触发前端 10s 超时。 参照 clips_standalone.py 模式提供别名端点,template_id 缺省时兜底到用户默认模板。🚀 预览环境已部署
🗑️ 预览环境已清理
PR #2033 已关闭或合并,对应的预览环境已被清理。