Fix: Add missing env vars to Settings class and remove inline comments from .env

- Added API_RELOAD, CORS_ORIGINS to Settings
- Added deployment-specific vars: POSTGRES_*, RELEASE_VERSION, GITEA_URL, GITHUB_TOKEN, GITHUB_REPO
- Removed inline comments from boolean values (Pydantic can't parse them)
- Updated CORS middleware to use CORS_ORIGINS with fallback to ALLOWED_ORIGINS
This commit is contained in:
Christian 2025-12-17 17:28:50 +01:00
parent 87c729a4c6
commit 2361bd2277
3 changed files with 18 additions and 4 deletions

View File

@ -67,5 +67,6 @@ ECONOMIC_AGREEMENT_GRANT_TOKEN=your_production_grant_here
# 🚨 SAFETY SWITCHES
# Start ALTID med begge sat til true i ny production deployment!
ECONOMIC_READ_ONLY=true # Set to false after thorough testing
ECONOMIC_DRY_RUN=true # Set to false when ready for live writes
# VIGTIGT: Brug kun 'true' eller 'false' uden kommentarer på samme linje
ECONOMIC_READ_ONLY=true
ECONOMIC_DRY_RUN=true

View File

@ -17,10 +17,12 @@ class Settings(BaseSettings):
# API
API_HOST: str = "0.0.0.0"
API_PORT: int = 8000
API_RELOAD: bool = False
# Security
SECRET_KEY: str = "dev-secret-key-change-in-production"
ALLOWED_ORIGINS: List[str] = ["http://localhost:8000", "http://localhost:3000"]
CORS_ORIGINS: str = "http://localhost:8000,http://localhost:3000"
# Logging
LOG_LEVEL: str = "INFO"
@ -65,6 +67,16 @@ class Settings(BaseSettings):
SIMPLYCRM_USERNAME: str = ""
SIMPLYCRM_API_KEY: str = ""
# Deployment Configuration (used by Docker/Podman)
POSTGRES_USER: str = "bmc_hub"
POSTGRES_PASSWORD: str = "bmc_hub"
POSTGRES_DB: str = "bmc_hub"
POSTGRES_PORT: int = 5432
RELEASE_VERSION: str = "latest"
GITEA_URL: str = "https://g.bmcnetworks.dk"
GITHUB_TOKEN: str = ""
GITHUB_REPO: str = "ct/bmc_hub"
class Config:
env_file = ".env"
case_sensitive = True

View File

@ -79,10 +79,11 @@ app = FastAPI(
openapi_url="/api/openapi.json"
)
# CORS middleware
# CORS middleware - use CORS_ORIGINS if set, otherwise fallback to ALLOWED_ORIGINS
cors_origins = settings.CORS_ORIGINS.split(",") if settings.CORS_ORIGINS else settings.ALLOWED_ORIGINS
app.add_middleware(
CORSMiddleware,
allow_origins=settings.ALLOWED_ORIGINS,
allow_origins=cors_origins,
allow_credentials=True,
allow_methods=["*"],
allow_headers=["*"],