后端: - 实现登出 API(清除 refresh token) - 清除 videos.py 中已被 Celery 任务取代的死代码 - 添加速率限制中间件(60次/分钟,登录10次/分钟) - 添加 SECRET_KEY/ENCRYPTION_KEY 默认值警告 - OSS STS 方法回退到 Policy 签名(不再抛异常) 前端: - 添加全局 404/error/loading 页面 - 添加三端 error.tsx + loading.tsx 错误边界 - 修复 useId 条件调用违反 Hooks 规则 - 修复未转义引号和 Image 命名冲突 - 添加 ESLint 配置 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
53 lines
1.8 KiB
Python
53 lines
1.8 KiB
Python
"""FastAPI 应用入口"""
|
|
from fastapi import FastAPI
|
|
from fastapi.middleware.cors import CORSMiddleware
|
|
from app.config import settings
|
|
from app.middleware.rate_limit import RateLimitMiddleware
|
|
from app.api import health, auth, upload, scripts, videos, tasks, rules, ai_config, sse, projects, briefs, organizations, dashboard
|
|
|
|
# 创建应用
|
|
app = FastAPI(
|
|
title=settings.APP_NAME,
|
|
version=settings.APP_VERSION,
|
|
description="AI 营销内容合规审核平台 API",
|
|
docs_url="/docs" if settings.DEBUG else None,
|
|
redoc_url="/redoc" if settings.DEBUG else None,
|
|
)
|
|
|
|
# CORS 配置
|
|
app.add_middleware(
|
|
CORSMiddleware,
|
|
allow_origins=["*"] if settings.DEBUG else ["https://miaosi.ai"],
|
|
allow_credentials=True,
|
|
allow_methods=["*"],
|
|
allow_headers=["*"],
|
|
)
|
|
|
|
# Rate limiting
|
|
app.add_middleware(RateLimitMiddleware, default_limit=60, window_seconds=60)
|
|
|
|
# 注册路由
|
|
app.include_router(health.router, prefix="/api/v1")
|
|
app.include_router(auth.router, prefix="/api/v1")
|
|
app.include_router(upload.router, prefix="/api/v1")
|
|
app.include_router(scripts.router, prefix="/api/v1")
|
|
app.include_router(videos.router, prefix="/api/v1")
|
|
app.include_router(tasks.router, prefix="/api/v1")
|
|
app.include_router(rules.router, prefix="/api/v1")
|
|
app.include_router(ai_config.router, prefix="/api/v1")
|
|
app.include_router(sse.router, prefix="/api/v1")
|
|
app.include_router(projects.router, prefix="/api/v1")
|
|
app.include_router(briefs.router, prefix="/api/v1")
|
|
app.include_router(organizations.router, prefix="/api/v1")
|
|
app.include_router(dashboard.router, prefix="/api/v1")
|
|
|
|
|
|
@app.get("/")
|
|
async def root():
|
|
"""根路径"""
|
|
return {
|
|
"message": f"Welcome to {settings.APP_NAME}",
|
|
"version": settings.APP_VERSION,
|
|
"docs": "/docs" if settings.DEBUG else "disabled",
|
|
}
|