## Database Migration (SQLite → MySQL) - Add Alembic migration framework - Add 'tr_' prefix to all tables to avoid conflicts in shared database - Remove SQLite support, use MySQL exclusively - Add pymysql driver dependency - Change ad_token column to Text type for long JWT tokens ## Unified Environment Configuration - Centralize all hardcoded settings to environment variables - Backend: Extend Settings class in app/core/config.py - Frontend: Use Vite environment variables (import.meta.env) - Docker: Move credentials to environment variables - Update .env.example files with comprehensive documentation ## Test Organization - Move root-level test files to tests/ directory: - test_chat_room.py → tests/test_chat_room.py - test_websocket.py → tests/test_websocket.py - test_realtime_implementation.py → tests/test_realtime_implementation.py - Fix path references in test_realtime_implementation.py Breaking Changes: - CORS now requires explicit origins (no more wildcard) - All database tables renamed with 'tr_' prefix - SQLite no longer supported 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
2.9 KiB
2.9 KiB
Change: Unified Environment Configuration Management
Why
目前專案中存在多處硬編碼的設定值(端口、URL、超時時間、檔案大小限制等),分散在後端 Python 程式碼、前端 TypeScript 程式碼、Docker 配置檔案及開發腳本中。這造成:
- 部署困難:每次部署到不同環境需要修改多個檔案
- 安全風險:CORS 使用萬用字元
["*"]、MinIO 使用預設密碼 - 維護成本:設定值分散在 20+ 個檔案中,難以追蹤和更新
- 環境一致性問題:開發、測試、生產環境難以保持設定同步
What Changes
Backend Configuration (Python)
- 將所有硬編碼的設定值移至
app/core/config.py的 Settings 類別 - 擴展
.env文件以包含所有可配置項目 - 新增以下環境變數:
HOST,PORT,DEBUG- 伺服器設定CORS_ORIGINS- CORS 來源白名單(BREAKING: 移除萬用字元)SYSTEM_ADMIN_EMAIL- 系統管理員信箱AD_API_TIMEOUT_SECONDS- AD API 超時設定MESSAGE_EDIT_TIME_LIMIT_MINUTES- 訊息編輯時間限制TYPING_TIMEOUT_SECONDS- 打字指示器超時IMAGE_MAX_SIZE_MB,DOCUMENT_MAX_SIZE_MB,LOG_MAX_SIZE_MB- 檔案大小限制LOG_LEVEL- 日誌等級
Frontend Configuration (TypeScript/Vite)
- 使用 Vite 環境變數機制 (
import.meta.env) - 新增以下環境變數:
VITE_API_TIMEOUT_MS- API 請求超時VITE_MESSAGES_REFETCH_INTERVAL_MS- 訊息重新取得間隔VITE_MAX_RECONNECT_DELAY_MS- WebSocket 重連延遲VITE_REPORTS_STALE_TIME_MS- 報告快取過期時間VITE_PORT- 開發伺服器端口VITE_BACKEND_URL- 後端 API URL
Docker Configuration
- 將
docker-compose.minio.yml中的硬編碼認證資訊改為環境變數 - 新增
.env.docker範例檔案
Documentation
- 更新
.env.example包含所有環境變數及說明 - 更新
frontend/.env.example包含所有前端環境變數
Impact
- Affected specs: 新增
env-configspec - Affected code:
app/core/config.py- 擴展 Settings 類別app/main.py- CORS 設定改為從環境變數讀取app/modules/realtime/router.py- SYSTEM_ADMIN_EMAILapp/modules/auth/services/ad_client.py- AD API 超時app/modules/realtime/services/message_service.py- 訊息編輯限制app/modules/realtime/websocket_manager.py- 打字超時app/modules/file_storage/validators.py- 檔案大小限制frontend/vite.config.ts- 端口和後端 URLfrontend/src/services/api.ts- API 超時frontend/src/hooks/*.ts- 各種超時和間隔設定docker-compose.minio.yml- MinIO 認證.env.example,frontend/.env.example- 文件更新
- Breaking changes:
- CORS 設定從
["*"]改為必須明確指定來源 - 新的必要環境變數可能導致現有部署需要更新
.env檔案
- CORS 設定從