Skip to content

Commit 900b6f6

Browse files
Refactor ALLOWED_HOSTS and security settings
1 parent 88a0899 commit 900b6f6

File tree

1 file changed

+7
-10
lines changed

1 file changed

+7
-10
lines changed

argus_ia/settings.py

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,11 @@
1212

1313
DEBUG = os.environ.get('DEBUG', 'False').lower() == 'true'
1414

15-
ALLOWED_HOSTS = ['argus-ia.up.railway.app', 'localhost', '127.0.0.1']
15+
ALLOWED_HOSTS = [
16+
host.strip()
17+
for host in os.environ.get('ALLOWED_HOSTS', 'localhost,127.0.0.1').split(',')
18+
]
19+
1620

1721
INSTALLED_APPS = [
1822
'django.contrib.admin',
@@ -121,21 +125,14 @@
121125
# Segurança em produção — NÃO aplicar no ambiente local
122126
# Segurança em produção
123127
if not DEBUG:
124-
# Cookies seguros no ambiente de produção
125128
SESSION_COOKIE_SECURE = True
126129
CSRF_COOKIE_SECURE = True
127-
128-
# Railway NÃO aceita redirecionamento SSL dentro do container
129130
SECURE_SSL_REDIRECT = False
130-
131-
# HSTS pode ficar ativo
132-
SECURE_HSTS_SECONDS = 31536000
133-
SECURE_HSTS_INCLUDE_SUBDOMAINS = True
134-
SECURE_HSTS_PRELOAD = True
131+
SECURE_HSTS_SECONDS = 0 # evitar bloqueios durante teste
135132
else:
136-
# Ambiente local
137133
SESSION_COOKIE_SECURE = False
138134
CSRF_COOKIE_SECURE = False
139135
SECURE_SSL_REDIRECT = False
140136

137+
141138
PORT = os.environ.get('PORT', 8000)

0 commit comments

Comments
 (0)