Dama12 commited on
Commit
0351a61
·
1 Parent(s): fa156f1

Fix ALLOWED_ORIGINS pydantic parsing on HF

Browse files
Files changed (1) hide show
  1. app/core/settings.py +10 -5
app/core/settings.py CHANGED
@@ -38,12 +38,17 @@ class Settings(BaseSettings):
38
  # Frontend URL (Used for OAuth redirects)
39
  FRONTEND_URL: str = "http://localhost:3000"
40
 
41
- # CORS — comma-separated list of allowed origins
42
  ALLOWED_ORIGINS: List[str] = ["http://localhost:3000"]
43
-
44
- # K2 Think API
45
- K2_THINK_API_KEY: Optional[str] = None
46
- K2_THINK_API_URL: str = "https://api.k2think.com/v1"
 
 
 
 
 
47
 
48
  # OpenAI/LLM
49
  OPENAI_API_KEY: Optional[str] = None
 
38
  # Frontend URL (Used for OAuth redirects)
39
  FRONTEND_URL: str = "http://localhost:3000"
40
 
41
+ # CORS — array or comma-separated list of allowed origins
42
  ALLOWED_ORIGINS: List[str] = ["http://localhost:3000"]
43
+
44
+ @field_validator("ALLOWED_ORIGINS", mode="before")
45
+ @classmethod
46
+ def assemble_cors_origins(cls, v: str | List[str]) -> List[str]:
47
+ if isinstance(v, str) and not v.startswith("["):
48
+ return [i.strip() for i in v.split(",") if i.strip()]
49
+ elif isinstance(v, (list, str)):
50
+ return v
51
+ raise ValueError(v)
52
 
53
  # OpenAI/LLM
54
  OPENAI_API_KEY: Optional[str] = None