fastapi-demo/.env.example

72 lines
1.8 KiB
Plaintext
Raw Permalink Normal View History

2025-09-28 08:40:27 +08:00
# FastAPI 演示项目环境配置模板
# 复制此文件为 .env 并根据实际情况修改配置
# === 应用基础配置 ===
PROJECT_NAME=FastAPI Demo
VERSION=1.0.0
DEBUG=True
ENVIRONMENT=development
2025-09-28 08:40:27 +08:00
# === 服务器配置 ===
HOST=0.0.0.0
PORT=8000
LOG_LEVEL=info
2025-09-28 08:40:27 +08:00
# WORKERS=1 # 生产环境可设置多个 worker
# RELOAD=True # 开发环境开启热重载
2025-09-28 08:40:27 +08:00
# === MySQL 数据库配置 ===
# 请根据实际环境修改数据库连接信息
DB_HOST=localhost
DB_PORT=3306
DB_USER=your_db_user
DB_PASSWORD=your_db_password
DB_NAME=your_database_name
DB_CHARSET=utf8mb4
2025-09-28 08:40:27 +08:00
# === 数据库连接池配置 ===
DB_ECHO=False # 开启后会打印 SQL 语句,调试时可设为 True
DB_POOL_SIZE=5
DB_MAX_OVERFLOW=10
2025-09-28 08:40:27 +08:00
DB_POOL_TIMEOUT=30
DB_POOL_RECYCLE=3600
2025-09-28 08:40:27 +08:00
# === Redis 配置(可选) ===
REDIS_HOST=localhost
REDIS_PORT=6379
REDIS_DB=0
2025-09-28 08:40:27 +08:00
# REDIS_PASSWORD=your_redis_password
2025-09-28 08:40:27 +08:00
# === CORS 配置 ===
# 开发环境允许所有来源,生产环境应指定具体域名
CORS_ORIGINS=["*"]
# 生产环境示例CORS_ORIGINS=["https://yourdomain.com","https://api.yourdomain.com"]
2025-09-28 08:40:27 +08:00
# === JWT 配置 ===
# 生产环境必须使用强密钥至少32个字符
SECRET_KEY=your-secret-key-here-change-in-production
ACCESS_TOKEN_EXPIRE_MINUTES=30
REFRESH_TOKEN_EXPIRE_DAYS=7
2025-09-28 08:40:27 +08:00
# === API 文档配置 ===
# 生产环境建议关闭 API 文档
# DOCS_URL=/docs
# REDOC_URL=/redoc
# 关闭文档示例:
# DOCS_URL=
# REDOC_URL=
2025-09-28 08:40:27 +08:00
# === 邮件配置(可选) ===
# SMTP_HOST=smtp.yourdomain.com
# SMTP_PORT=587
# SMTP_USER=noreply@yourdomain.com
# SMTP_PASSWORD=your_smtp_password
# SMTP_FROM=noreply@yourdomain.com
2025-09-28 08:40:27 +08:00
# === 监控配置(可选) ===
# SENTRY_DSN=https://your-sentry-dsn@sentry.io/project-id
# PROMETHEUS_ENABLED=True
2025-09-28 08:40:27 +08:00
# === 限流配置(可选) ===
# RATE_LIMIT_ENABLED=True
# RATE_LIMIT_REQUESTS=100
# RATE_LIMIT_PERIOD=60