Prepare accounting backend for production behind nginx and CDN proxy.
Add reverse-proxy settings, stricter CORS origin parsing, and production env defaults for acc.zoneco.org and the admin panel.
This commit is contained in:
@@ -18,10 +18,19 @@ SECRET_KEY = config('SECRET_KEY', default='your-super-secret-key-change-in-produ
|
||||
|
||||
DEBUG = config('DEBUG', default=True, cast=bool)
|
||||
|
||||
ALLOWED_HOSTS = config(
|
||||
'ALLOWED_HOSTS',
|
||||
default='localhost,127.0.0.1,0.0.0.0,testserver',
|
||||
).split(',')
|
||||
ALLOWED_HOSTS = [
|
||||
host.strip()
|
||||
for host in config(
|
||||
'ALLOWED_HOSTS',
|
||||
default='localhost,127.0.0.1,0.0.0.0,testserver',
|
||||
).split(',')
|
||||
if host.strip()
|
||||
]
|
||||
|
||||
# Behind nginx / CDN reverse proxy
|
||||
USE_X_FORWARDED_HOST = config('USE_X_FORWARDED_HOST', default=False, cast=bool)
|
||||
if config('SECURE_PROXY_SSL_HEADER', default=False, cast=bool):
|
||||
SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https')
|
||||
|
||||
INSTALLED_APPS = [
|
||||
'django.contrib.auth',
|
||||
@@ -120,7 +129,30 @@ SIMPLE_JWT = {
|
||||
# CORS: allow the accounting frontend (and others) in development.
|
||||
CORS_ALLOW_ALL_ORIGINS = config('CORS_ALLOW_ALL_ORIGINS', default=True, cast=bool)
|
||||
CORS_ALLOW_CREDENTIALS = True
|
||||
CORS_ALLOWED_ORIGINS = config(
|
||||
'CORS_ALLOWED_ORIGINS',
|
||||
default='http://localhost:5176,http://127.0.0.1:5176',
|
||||
).split(',')
|
||||
CORS_ALLOWED_ORIGINS = [
|
||||
origin.strip()
|
||||
for origin in config(
|
||||
'CORS_ALLOWED_ORIGINS',
|
||||
default='http://localhost:5176,http://127.0.0.1:5176',
|
||||
).split(',')
|
||||
if origin.strip()
|
||||
]
|
||||
CORS_ALLOW_HEADERS = [
|
||||
'accept',
|
||||
'accept-encoding',
|
||||
'authorization',
|
||||
'content-type',
|
||||
'dnt',
|
||||
'origin',
|
||||
'user-agent',
|
||||
'x-csrftoken',
|
||||
'x-requested-with',
|
||||
]
|
||||
CORS_ALLOW_METHODS = [
|
||||
'DELETE',
|
||||
'GET',
|
||||
'OPTIONS',
|
||||
'PATCH',
|
||||
'POST',
|
||||
'PUT',
|
||||
]
|
||||
|
||||
Reference in New Issue
Block a user