File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 2121# Build paths inside the project like this: BASE_DIR / 'subdir'.
2222BASE_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
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
6671ROOT_URLCONF = "api.urls"
6772
You can’t perform that action at this time.
0 commit comments