diff --git a/CTOAsYouGo/CTOAsYouGo/settings.py b/CTOAsYouGo/CTOAsYouGo/settings.py index 31c6ae3..8b2cc13 100644 --- a/CTOAsYouGo/CTOAsYouGo/settings.py +++ b/CTOAsYouGo/CTOAsYouGo/settings.py @@ -17,6 +17,7 @@ import dj_database_url # Build paths inside the project like this: BASE_DIR / 'subdir'. BASE_DIR = Path(__file__).resolve().parent.parent +RUNNING_ON_HEROKU = 'DATABASE_URL' in os.environ # Quick-start development settings - unsuitable for production # See https://docs.djangoproject.com/en/4.2/howto/deployment/checklist/ @@ -25,7 +26,8 @@ BASE_DIR = Path(__file__).resolve().parent.parent SECRET_KEY = 'django-insecure-d8gmbk-g2&ue)k_74169!l@oiue8ra%@d4qm@jc=3&%&*%(oah' # SECURITY WARNING: don't run with debug turned on in production! -DEBUG = True +if not RUNNING_ON_HEROKU: + DEBUG = True ALLOWED_HOSTS = ['localhost', '127.0.0.1', 'ctoasyougo.com', 'www.ctoasyougo.com','ctoasyougo-3015a1b209e7.herokuapp.com'] @@ -55,6 +57,10 @@ MIDDLEWARE = [ 'django.middleware.clickjacking.XFrameOptionsMiddleware', ] +if RUNNING_ON_HEROKU: + SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https') + SECURE_SSL_REDIRECT = True + ROOT_URLCONF = 'CTOAsYouGo.urls' TEMPLATES = [ @@ -79,7 +85,7 @@ WSGI_APPLICATION = 'CTOAsYouGo.wsgi.application' # Database # https://docs.djangoproject.com/en/4.2/ref/settings/#databases -if 'DATABASE_URL' in os.environ: +if RUNNING_ON_HEROKU: DATABASES = { 'default': dj_database_url.config() }