Spaces:
Sleeping
Sleeping
Fix ALLOWED_ORIGINS pydantic parsing on HF
Browse files- 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 |
-
|
| 45 |
-
|
| 46 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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
|