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:
parent
87c729a4c6
commit
2361bd2277
@ -67,5 +67,6 @@ ECONOMIC_AGREEMENT_GRANT_TOKEN=your_production_grant_here
|
|||||||
|
|
||||||
# 🚨 SAFETY SWITCHES
|
# 🚨 SAFETY SWITCHES
|
||||||
# Start ALTID med begge sat til true i ny production deployment!
|
# Start ALTID med begge sat til true i ny production deployment!
|
||||||
ECONOMIC_READ_ONLY=true # Set to false after thorough testing
|
# VIGTIGT: Brug kun 'true' eller 'false' uden kommentarer på samme linje
|
||||||
ECONOMIC_DRY_RUN=true # Set to false when ready for live writes
|
ECONOMIC_READ_ONLY=true
|
||||||
|
ECONOMIC_DRY_RUN=true
|
||||||
|
|||||||
@ -17,10 +17,12 @@ class Settings(BaseSettings):
|
|||||||
# API
|
# API
|
||||||
API_HOST: str = "0.0.0.0"
|
API_HOST: str = "0.0.0.0"
|
||||||
API_PORT: int = 8000
|
API_PORT: int = 8000
|
||||||
|
API_RELOAD: bool = False
|
||||||
|
|
||||||
# Security
|
# Security
|
||||||
SECRET_KEY: str = "dev-secret-key-change-in-production"
|
SECRET_KEY: str = "dev-secret-key-change-in-production"
|
||||||
ALLOWED_ORIGINS: List[str] = ["http://localhost:8000", "http://localhost:3000"]
|
ALLOWED_ORIGINS: List[str] = ["http://localhost:8000", "http://localhost:3000"]
|
||||||
|
CORS_ORIGINS: str = "http://localhost:8000,http://localhost:3000"
|
||||||
|
|
||||||
# Logging
|
# Logging
|
||||||
LOG_LEVEL: str = "INFO"
|
LOG_LEVEL: str = "INFO"
|
||||||
@ -65,6 +67,16 @@ class Settings(BaseSettings):
|
|||||||
SIMPLYCRM_USERNAME: str = ""
|
SIMPLYCRM_USERNAME: str = ""
|
||||||
SIMPLYCRM_API_KEY: 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:
|
class Config:
|
||||||
env_file = ".env"
|
env_file = ".env"
|
||||||
case_sensitive = True
|
case_sensitive = True
|
||||||
|
|||||||
5
main.py
5
main.py
@ -79,10 +79,11 @@ app = FastAPI(
|
|||||||
openapi_url="/api/openapi.json"
|
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(
|
app.add_middleware(
|
||||||
CORSMiddleware,
|
CORSMiddleware,
|
||||||
allow_origins=settings.ALLOWED_ORIGINS,
|
allow_origins=cors_origins,
|
||||||
allow_credentials=True,
|
allow_credentials=True,
|
||||||
allow_methods=["*"],
|
allow_methods=["*"],
|
||||||
allow_headers=["*"],
|
allow_headers=["*"],
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user