GitHub Actions commited on
Commit
45be25a
·
1 Parent(s): 0810260

sync: github commit b1bdc223a3a61710138fb2155d022e887a21085e to HF Space

Browse files
Files changed (1) hide show
  1. app/core/config.py +15 -5
app/core/config.py CHANGED
@@ -10,15 +10,25 @@ class Settings(BaseSettings):
10
  ACCESS_TOKEN_EXPIRE_MINUTES: int = 60 * 24 * 8
11
 
12
  # CORS
13
- BACKEND_CORS_ORIGINS: List[AnyHttpUrl] = []
14
 
15
  @validator("BACKEND_CORS_ORIGINS", pre=True)
16
  def assemble_cors_origins(cls, v: Union[str, List[str]]) -> Union[List[str], str]:
17
- if isinstance(v, str) and not v.startswith("["):
18
- return [i.strip() for i in v.split(",")]
19
- elif isinstance(v, (list, str)):
 
 
 
 
 
 
 
 
 
20
  return v
21
- raise ValueError(v)
 
22
 
23
  # Database
24
  POSTGRES_SERVER: str = "localhost"
 
10
  ACCESS_TOKEN_EXPIRE_MINUTES: int = 60 * 24 * 8
11
 
12
  # CORS
13
+ BACKEND_CORS_ORIGINS: Union[str, List[str]] = ""
14
 
15
  @validator("BACKEND_CORS_ORIGINS", pre=True)
16
  def assemble_cors_origins(cls, v: Union[str, List[str]]) -> Union[List[str], str]:
17
+ if isinstance(v, str):
18
+ if not v.strip():
19
+ return []
20
+ if not v.startswith("["):
21
+ return [i.strip() for i in v.split(",")]
22
+ else:
23
+ import json
24
+ try:
25
+ return json.loads(v)
26
+ except Exception:
27
+ return [v]
28
+ elif isinstance(v, list):
29
  return v
30
+ return []
31
+
32
 
33
  # Database
34
  POSTGRES_SERVER: str = "localhost"