Skip to content

Commit

Permalink
Merge pull request #93 from observerly/feature/config/BACKEND_CORS_OR…
Browse files Browse the repository at this point in the history
…IGINS

feat: Amended BACKEND_CORS_ORIGINS in config.py BaseSettings.
  • Loading branch information
michealroberts committed Feb 9, 2023
2 parents 70abaf5 + f170551 commit 64824ab
Showing 1 changed file with 3 additions and 11 deletions.
14 changes: 3 additions & 11 deletions app/core/config.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from secrets import token_urlsafe
from typing import Any, Dict, List, Optional, Union
from typing import Any, Dict, List, Literal, Optional, Union

from pydantic import AnyHttpUrl, BaseSettings, EmailStr, HttpUrl, validator

Expand All @@ -24,16 +24,8 @@ class Settings(BaseSettings):
# BACKEND_CORS_ORIGINS is a JSON-formatted list of origins
# e.g: '["http://localhost", "http://localhost:3000", \
# "http://localhost:8080", "https://api.observerly.com"], \
# "https://perseus.observerly.com"'
BACKEND_CORS_ORIGINS: List[AnyHttpUrl] = [
"https://app.observerly.com",
"https://vega.observerly.com",
"https://observerly.com",
]

if PROJECT_ENVIRONMENT == "development":
for i in range(3000, 8000):
BACKEND_CORS_ORIGINS.append("http://localhost:{0}".format(i))
# "https://perseus.observerly.com]"':
BACKEND_CORS_ORIGINS: List[AnyHttpUrl | Literal["*"]] = ["*"]

@validator("BACKEND_CORS_ORIGINS", pre=True)
def assemble_cors_origins(cls, v: Union[str, List[str]]) -> Union[List[str], str]:
Expand Down

0 comments on commit 64824ab

Please sign in to comment.