🔧 Fix Django 4.0+ CSRF_TRUSTED_ORIGINS and CI settings
Some checks failed
continuous-integration/drone/push Build is failing
Some checks failed
continuous-integration/drone/push Build is failing
✅ Fixed issues: - Added proper CSRF_TRUSTED_ORIGINS with schemes (http://, https://) - Added missing sys import in test settings - Updated ALLOWED_HOSTS to include 'postgres' container - Removed duplicate database creation in CI pipeline - Fixed empty CSRF_TRUSTED_ORIGINS causing Django 4.0.E001 error 🐳 CI/CD improvements: - Database container properly referenced in settings - Test environment variables correctly configured - Eliminated database creation conflicts Ready for trusted repository CI/CD execution!
This commit is contained in:
@@ -1,12 +1,9 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
import os
|
||||
import sys
|
||||
import dj_database_url
|
||||
from .settings import *
|
||||
|
||||
# Переопределяем настройки для CI/CD тестирования
|
||||
|
||||
print("ALLOWED_HOSTS:", ALLOWED_HOSTS)
|
||||
print("CSRF_TRUSTED_ORIGINS:", CSRF_TRUSTED_ORIGINS)
|
||||
print("🧪 Test settings loaded")
|
||||
|
||||
# База данных для тестирования
|
||||
@@ -14,7 +11,7 @@ DATABASES = {
|
||||
'default': dj_database_url.config(
|
||||
default=os.environ.get(
|
||||
'DATABASE_URL',
|
||||
'postgresql://postgres:postgres@postgres_test:5432/smartsoltech_test'
|
||||
'postgresql://postgres:postgres@postgres:5432/smartsoltech_test'
|
||||
)
|
||||
)
|
||||
}
|
||||
@@ -33,6 +30,15 @@ DEBUG = os.environ.get('DEBUG', 'False').lower() in ['true', '1', 'yes']
|
||||
|
||||
# Разрешенные хосты для CI
|
||||
ALLOWED_HOSTS = os.environ.get('ALLOWED_HOSTS', 'localhost,127.0.0.1,postgres,*').split(',')
|
||||
|
||||
# CSRF настройки для тестирования
|
||||
CSRF_TRUSTED_ORIGINS = [
|
||||
'http://localhost',
|
||||
'http://127.0.0.1',
|
||||
'http://postgres',
|
||||
'https://smartsoltech.kr'
|
||||
]
|
||||
|
||||
print("🌐 Allowed hosts:", ALLOWED_HOSTS)
|
||||
|
||||
# Упрощенный хеширователь паролей для быстрых тестов
|
||||
|
||||
Reference in New Issue
Block a user