Fix ALLOWED_ORIGINS to accept comma-separated string
This commit is contained in:
@@ -17,11 +17,18 @@ class Settings(BaseSettings):
|
|||||||
ALGORITHM: str = "HS256"
|
ALGORITHM: str = "HS256"
|
||||||
ACCESS_TOKEN_EXPIRE_MINUTES: int = 30
|
ACCESS_TOKEN_EXPIRE_MINUTES: int = 30
|
||||||
|
|
||||||
# CORS
|
# CORS - accepts either comma-separated string or JSON array
|
||||||
ALLOWED_ORIGINS: List[str] = ["http://localhost:5173", "http://localhost:3000"]
|
ALLOWED_ORIGINS: str = "http://localhost:5173,http://localhost:3000"
|
||||||
|
|
||||||
class Config:
|
class Config:
|
||||||
env_file = ".env"
|
env_file = ".env"
|
||||||
case_sensitive = True
|
case_sensitive = True
|
||||||
|
|
||||||
|
@property
|
||||||
|
def cors_origins(self) -> List[str]:
|
||||||
|
"""Parse ALLOWED_ORIGINS into a list."""
|
||||||
|
if isinstance(self.ALLOWED_ORIGINS, str):
|
||||||
|
return [origin.strip() for origin in self.ALLOWED_ORIGINS.split(',')]
|
||||||
|
return self.ALLOWED_ORIGINS
|
||||||
|
|
||||||
settings = Settings()
|
settings = Settings()
|
||||||
|
|||||||
Reference in New Issue
Block a user