Fix CORS
This commit is contained in:
@@ -10,7 +10,8 @@ class Settings(BaseSettings):
|
||||
DATABASE_URL: str = "postgresql://audio_user:audio_password@localhost:5432/audio_classifier"
|
||||
|
||||
# API Configuration
|
||||
CORS_ORIGINS: str = "http://localhost:3000,http://127.0.0.1:3000"
|
||||
# Comma-separated list of allowed origins, or use "*" to allow all
|
||||
CORS_ORIGINS: str = "*"
|
||||
API_HOST: str = "0.0.0.0"
|
||||
API_PORT: int = 8000
|
||||
|
||||
@@ -33,7 +34,13 @@ class Settings(BaseSettings):
|
||||
|
||||
@property
|
||||
def cors_origins_list(self) -> List[str]:
|
||||
"""Parse CORS origins string to list."""
|
||||
"""Parse CORS origins string to list.
|
||||
|
||||
If CORS_ORIGINS is "*", allow all origins.
|
||||
Otherwise, parse comma-separated list.
|
||||
"""
|
||||
if self.CORS_ORIGINS.strip() == "*":
|
||||
return ["*"]
|
||||
return [origin.strip() for origin in self.CORS_ORIGINS.split(",")]
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user