chore: update CORS and ALLOWED_HOSTS settings

This commit is contained in:
Chneemann 2025-04-14 23:26:50 +02:00
parent 7c96da524b
commit 0618afbbea
2 changed files with 25 additions and 21 deletions

View file

@ -21,24 +21,29 @@ BASE_DIR = Path(__file__).resolve().parent.parent
# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/5.1/howto/deployment/checklist/
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = 'django-insecure-9)^^*tvi%nrcooazhtd&s*9@capcuv5j0u_9+))s-#2q@uw+%s'
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
ALLOWED_HOSTS = [
ALLOWED_HOSTS = [
'join.andre-kempf.com',
'join-api.andre-kempf.com',
'45.157.177.172',
'localhost',
'127.0.0.1',
]
# CORS settings
CORS_ALLOWED_ORIGINS = ['http://localhost:4200']
CORS_ALLOW_CREDENTIALS = True
CORS_ALLOWED_ORIGINS = [
'https://45.157.177.172',
'https://join.andre-kempf.com',
'http://localhost:4200']
CORS_ALLOW_HEADERS = [
'content-type', 'accept', 'authorization', 'x-csrftoken', 'sentry-trace', 'baggage',
]
# Application config
AUTH_USER_MODEL = 'user_app.User'
INSTALLED_APPS = [
@ -58,6 +63,7 @@ INSTALLED_APPS = [
]
MIDDLEWARE = [
'corsheaders.middleware.CorsMiddleware',
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
@ -65,7 +71,6 @@ MIDDLEWARE = [
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
'corsheaders.middleware.CorsMiddleware',
]
ROOT_URLCONF = 'join.urls'
@ -97,23 +102,16 @@ CACHES = {
'BACKEND': 'django_redis.cache.RedisCache',
'LOCATION': 'redis://127.0.0.1:6379/1',
'OPTIONS': {
'PASSWORD': 'foobared',
'CLIENT_CLASS': 'django_redis.client.DefaultClient',
}
},
'KEY_PREFIX': 'joinapi',
}
}
# Database
# https://docs.djangoproject.com/en/5.1/ref/settings/#databases
"""
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': BASE_DIR / 'db.sqlite3',
}
}
"""
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql',
@ -159,7 +157,9 @@ USE_TZ = True
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/5.1/howto/static-files/
STATIC_URL = 'static/'
STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles')
STATIC_URL = '/static/'
# Default primary key field type
# https://docs.djangoproject.com/en/5.1/ref/settings/#default-auto-field
@ -199,10 +199,12 @@ REST_FRAMEWORK = {
env = Env()
Env.read_env()
DEBUG = env.bool('DEBUG', default=False)
SECRET_KEY = env('SECRET_KEY')
# EMAIL
# Mail
EMAIL_USE_TLS = True
EMAIL_HOST = 'smtp.gmail.com'
EMAIL_PORT = 587

View file

@ -5,6 +5,8 @@ django-environ==0.12.0
django-redis==5.4.0
djangorestframework==3.15.2
djangorestframework-camel-case==1.4.2
gunicorn==23.0.0
psycopg2==2.9.10
psycopg2-binary==2.9.10
redis==5.2.1
sqlparse==0.5.3