diff --git a/app/core/config.py b/app/core/config.py index c80d0c3..58e79c2 100644 --- a/app/core/config.py +++ b/app/core/config.py @@ -6,6 +6,7 @@ from pydantic_settings import BaseSettings, SettingsConfigDict class Settings(BaseSettings): PROJECT_NAME: str = "TJWater Server" + ENVIRONMENT: str = "local" API_V1_STR: str = "/api/v1" # JWT 配置 diff --git a/app/main.py b/app/main.py index 401ddce..947647c 100644 --- a/app/main.py +++ b/app/main.py @@ -53,13 +53,17 @@ async def lifespan(app: FastAPI): logger.info("Database connections closed") +# 根据环境配置决定是否启用文档 +is_production = settings.ENVIRONMENT.lower() == "production" + app = FastAPI( lifespan=lifespan, title=settings.PROJECT_NAME, description="TJWater Server - 供水管网智能管理系统", version="1.0.0", - docs_url="/docs", - redoc_url="/redoc", + docs_url=None if is_production else "/docs", + redoc_url=None if is_production else "/redoc", + openapi_url=None if is_production else "/openapi.json", )