@@ -9,7 +9,8 @@ https://docs.djangoproject.com/en/5.2/topics/settings/ |
| 9 | 9 | For the full list of settings and their values, see |
| 10 | 10 | https://docs.djangoproject.com/en/5.2/ref/settings/ |
| 11 | 11 | """ |
| 12 | | - |
| 12 | +import os |
| 13 | +import dj_database_url |
| 13 | 14 | from pathlib import Path |
| 14 | 15 | |
| 15 | 16 | # Build paths inside the project like this: BASE_DIR / 'subdir'. |
@@ -25,8 +26,22 @@ SECRET_KEY = "django-insecure-xykf5$__a(xn*avfxs2njr#==cn7*+t8kg+4_lbi$(#+@5_j8g |
| 25 | 26 | # SECURITY WARNING: don't run with debug turned on in production! |
| 26 | 27 | DEBUG = True |
| 27 | 28 | |
| 28 | | -ALLOWED_HOSTS = [] |
| 29 | +ALLOWED_HOSTS = [ |
| 30 | + 'localhost', |
| 31 | + '127.0.0.1', |
| 32 | + '.railway.app', |
| 33 | + '.up.railway.app', |
| 34 | +] |
| 35 | + |
| 36 | +# Database - Railway provides DATABASE_URL automatically |
| 37 | +if os.environ.get('DATABASE_URL'): |
| 38 | + DATABASES = { |
| 39 | + 'default': dj_database_url.parse(os.environ.get('DATABASE_URL')) |
| 40 | + } |
| 29 | 41 | |
| 42 | +# Static files |
| 43 | +STATIC_URL = '/static/' |
| 44 | +STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles') |
| 30 | 45 | |
| 31 | 46 | # Application definition |
| 32 | 47 | |
@@ -52,6 +67,7 @@ MIDDLEWARE = [ |
| 52 | 67 | "django.middleware.clickjacking.XFrameOptionsMiddleware", |
| 53 | 68 | 'corsheaders.middleware.CorsMiddleware', |
| 54 | 69 | 'django.middleware.common.CommonMiddleware', |
| 70 | + "whitenoise.middleware.WhiteNoiseMiddleware", |
| 55 | 71 | ] |
| 56 | 72 | |
| 57 | 73 | ROOT_URLCONF = "bashamole.urls" |
@@ -136,3 +152,6 @@ REST_FRAMEWORK = { |
| 136 | 152 | 'DEFAULT_PAGINATION_CLASS': 'rest_framework.pagination.PageNumberPagination', |
| 137 | 153 | 'PAGE_SIZE': 100 |
| 138 | 154 | } |
| 155 | + |
| 156 | +if os.environ.get('FRONTEND_URL'): |
| 157 | + CORS_ALLOWED_ORIGINS.append(os.environ.get('FRONTEND_URL')) |