Skip to content

Commit 7196801

Browse files
committed
fixed issue where settings would prevent migrate
1 parent 8e29278 commit 7196801

2 files changed

Lines changed: 10 additions & 5 deletions

File tree

server/api/settings.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,18 +21,18 @@
2121
# Build paths inside the project like this: BASE_DIR / 'subdir'.
2222
BASE_DIR = Path(__file__).resolve().parent.parent
2323

24-
FRONTEND_URL = os.environ.get("FRONTEND_URL")
24+
FRONTEND_URL: str | None = os.environ.get("FRONTEND_URL")
2525

2626
# Quick-start development settings - unsuitable for production
2727
# See https://docs.djangoproject.com/en/5.0/howto/deployment/checklist/
2828

2929
# SECURITY WARNING: keep the secret key used in production secret!
30-
SECRET_KEY = os.environ.get("API_SECRET_KEY")
30+
SECRET_KEY: str | None = os.environ.get("API_SECRET_KEY")
3131

3232
# SECURITY WARNING: don't run with debug turned on in production!
33-
DEBUG = os.environ.get("APP_ENV") == "DEVELOPMENT"
33+
DEBUG: bool = os.environ.get("APP_ENV", "DEVELOPMENT") == "DEVELOPMENT"
3434

35-
ALLOWED_HOSTS = os.environ.get("API_ALLOWED_HOSTS").split() if os.environ.get("API_ALLOWED_HOSTS") else []
35+
ALLOWED_HOSTS: list[str] = os.environ.get("API_ALLOWED_HOSTS").split() if os.environ.get("API_ALLOWED_HOSTS") else []
3636

3737

3838
# Application definition
@@ -61,7 +61,12 @@
6161
"corsheaders.middleware.CorsMiddleware",
6262
]
6363

64-
CORS_ALLOWED_ORIGINS = ["http://localhost:3000", "http://127.0.0.1:3000", FRONTEND_URL]
64+
65+
CORS_ALLOWED_ORIGINS: list[str] = []
66+
if DEBUG:
67+
CORS_ALLOWED_ORIGINS.extend(["http://localhost:3000", "http://127.0.0.1:3000"])
68+
if FRONTEND_URL:
69+
CORS_ALLOWED_ORIGINS.append(FRONTEND_URL)
6570

6671
ROOT_URLCONF = "api.urls"
6772

server/manage.py

100644100755
File mode changed.

0 commit comments

Comments
 (0)