Some checks failed
CI/CD - Build & Test / Backend Tests (push) Has been cancelled
CI/CD - Build & Test / Frontend Tests (push) Has been cancelled
CI/CD - Build & Test / Security Scans (push) Has been cancelled
CI/CD - Build & Test / Docker Build Test (push) Has been cancelled
CI/CD - Build & Test / Terraform Validate (push) Has been cancelled
Deploy to Production / Build & Test (push) Has been cancelled
Deploy to Production / Security Scan (push) Has been cancelled
Deploy to Production / Build Docker Images (push) Has been cancelled
Deploy to Production / Deploy to Staging (push) Has been cancelled
Deploy to Production / E2E Tests (push) Has been cancelled
Deploy to Production / Deploy to Production (push) Has been cancelled
E2E Tests / Run E2E Tests (push) Has been cancelled
E2E Tests / Visual Regression Tests (push) Has been cancelled
E2E Tests / Smoke Tests (push) Has been cancelled
The issue was duplicate CORS middleware configuration: - CORS was configured in main.py (correctly) - CORS was also configured in security_headers.py (incorrectly) The security_headers.py version was trying to instantiate CORSMiddleware directly without the 'app' argument, causing: TypeError: CORSMiddleware.__init__() missing 1 required positional argument: 'app' Fixed by: 1. Removed CORS middleware from setup_security_middleware() 2. Updated config.py to include http://localhost:8888 in CORS origins 3. Kept CORS configuration only in main.py Backend now starts successfully and responds to health checks.
79 lines
2.1 KiB
Python
79 lines
2.1 KiB
Python
"""Application configuration."""
|
|
|
|
from functools import lru_cache
|
|
from pydantic_settings import BaseSettings
|
|
from typing import List, Optional
|
|
|
|
|
|
class Settings(BaseSettings):
|
|
"""Application settings from environment variables."""
|
|
|
|
# Application
|
|
app_name: str = "mockupAWS"
|
|
app_version: str = "1.0.0"
|
|
debug: bool = False
|
|
log_level: str = "INFO"
|
|
json_logging: bool = True
|
|
|
|
# Database - default uses 'postgres' hostname for Docker, fallback to localhost for local dev
|
|
database_url: str = "postgresql+asyncpg://postgres:postgres@postgres:5432/mockupaws"
|
|
|
|
# Redis
|
|
redis_url: str = "redis://localhost:6379/0"
|
|
cache_disabled: bool = False
|
|
|
|
# Celery
|
|
celery_broker_url: str = "redis://localhost:6379/1"
|
|
celery_result_backend: str = "redis://localhost:6379/2"
|
|
|
|
# Pagination
|
|
default_page_size: int = 20
|
|
max_page_size: int = 100
|
|
|
|
# Report Storage
|
|
reports_storage_path: str = "./storage/reports"
|
|
reports_max_file_size_mb: int = 50
|
|
reports_cleanup_days: int = 30
|
|
reports_rate_limit_per_minute: int = 10
|
|
|
|
# JWT Configuration
|
|
jwt_secret_key: str = "super-secret-change-in-production"
|
|
jwt_algorithm: str = "HS256"
|
|
access_token_expire_minutes: int = 30
|
|
refresh_token_expire_days: int = 7
|
|
|
|
# Security
|
|
bcrypt_rounds: int = 12
|
|
cors_allowed_origins: List[str] = ["http://localhost:3000", "http://localhost:5173", "http://localhost:8888"]
|
|
cors_allowed_origins_production: List[str] = ["http://localhost:8888"]
|
|
|
|
# Audit Logging
|
|
audit_logging_enabled: bool = True
|
|
audit_database_url: Optional[str] = None
|
|
|
|
# Tracing
|
|
jaeger_endpoint: Optional[str] = None
|
|
jaeger_port: int = 6831
|
|
otlp_endpoint: Optional[str] = None
|
|
|
|
# Email
|
|
smtp_host: str = "localhost"
|
|
smtp_port: int = 587
|
|
smtp_user: Optional[str] = None
|
|
smtp_password: Optional[str] = None
|
|
default_from_email: str = "noreply@mockupaws.com"
|
|
|
|
class Config:
|
|
env_file = ".env"
|
|
case_sensitive = False
|
|
extra = "ignore"
|
|
|
|
|
|
@lru_cache()
|
|
def get_settings() -> Settings:
|
|
"""Get cached settings instance."""
|
|
return Settings()
|
|
|
|
|
|
settings = get_settings()
|