fix: P0 - 禁用 redirect_slashes 修复 307 重定向导致前端新建失败 #85
Reference in New Issue
Block a user
Delete Branch "fix/p0-307-redirect"
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?
问题
FastAPI 默认 redirect_slashes=True,当请求路径缺少尾斜杠时返回 307 重定向。在反向代理(Nginx)后面,307 重定向 URL 使用 http:// 而非 https://,导致前端 POST /api/v1/titles 等请求失败(新建失败)。
修复
优先级
P0 - 阻塞前端新建功能
- FastAPI 初始化添加 redirect_slashes=False,避免反向代理后 307 重定向 URL 丢失 HTTPS 协议 - 移除 titles.py/voices.py/generation_tasks.py 路由中的尾斜杠 ('/' → '','/tasks/' → '/tasks','/tasks/{id}/results/' → '/tasks/{id}/results') Fixes: 前端调用 POST /api/v1/titles 等接口时 307 重定向到 http:// 导致失败