|
8 | 8 |
|
9 | 9 | load_dotenv() |
10 | 10 |
|
11 | | -# Build paths inside the project like this: BASE_DIR / 'subdir'. |
12 | 11 | BASE_DIR = Path(__file__).resolve().parent.parent |
13 | 12 |
|
14 | | -# SECURITY WARNING: keep the secret key used in production secret! |
15 | 13 | SECRET_KEY = os.getenv('SECRET_KEY', 'django-insecure-4!)sv6=xv!rd-%py*h**vhrm)m(%-_2^j()bs&j9uj2u8!fkv6') |
16 | | - |
17 | | -# SECURITY WARNING: don't run with debug turned on in production! |
18 | 14 | DEBUG = os.getenv('DEBUG', 'True') == 'True' |
19 | | - |
20 | 15 | ALLOWED_HOSTS = os.getenv('ALLOWED_HOSTS', '').split(',') if os.getenv('ALLOWED_HOSTS') else ['*'] |
21 | 16 |
|
22 | | -# Application definition |
23 | 17 | INSTALLED_APPS = [ |
24 | 18 | 'django.contrib.admin', |
25 | 19 | 'django.contrib.auth', |
|
35 | 29 | ] |
36 | 30 |
|
37 | 31 | MIDDLEWARE = [ |
38 | | - 'corsheaders.middleware.CorsMiddleware', # Preflight and CORS must be FIRST |
| 32 | + 'corsheaders.middleware.CorsMiddleware', # MUST BE FIRST |
39 | 33 | 'django.middleware.security.SecurityMiddleware', |
40 | 34 | 'whitenoise.middleware.WhiteNoiseMiddleware', |
41 | 35 | 'django.contrib.sessions.middleware.SessionMiddleware', |
|
48 | 42 |
|
49 | 43 | ROOT_URLCONF = 'core.urls' |
50 | 44 |
|
51 | | -# IMPORTANT: User requested no trailing slashes. |
52 | | -# Disabling APPEND_SLASH prevents Django from automatically redirecting to / versions. |
53 | | -APPEND_SLASH = False |
| 45 | +# User requested no trailing slashes, but we enable APPEND_SLASH=True |
| 46 | +# to handle legacy/misconfigured tools gracefully. |
| 47 | +# Our URL patterns will handle both cases. |
| 48 | +APPEND_SLASH = True |
54 | 49 |
|
55 | 50 | TEMPLATES = [ |
56 | 51 | { |
|
68 | 63 | ] |
69 | 64 |
|
70 | 65 | WSGI_APPLICATION = 'core.wsgi.application' |
71 | | - |
72 | | -# Database |
73 | 66 | DATABASES = {} |
74 | 67 |
|
75 | | -# CORS settings - Bulletproof for Netlify migration |
| 68 | +# --- BULLETPROOF CORS CONFIG --- |
76 | 69 | CORS_ALLOW_ALL_ORIGINS = True |
77 | | -CORS_ORIGIN_ALLOW_ALL = True # Legacy compatibility |
78 | 70 | CORS_ALLOW_CREDENTIALS = True |
79 | | - |
80 | | -# Explicitly Trusting modern origins to prevent browser-side rejections |
81 | | -CORS_ALLOWED_ORIGINS = [ |
82 | | - "https://hrms-lite-frontend.vercel.app", |
83 | | - "https://hrms-lite-version.netlify.app", |
84 | | -] |
85 | | - |
86 | 71 | CORS_ALLOWED_ORIGIN_REGEXES = [ |
87 | 72 | r"^https://.*\.netlify\.app$", |
88 | | - r"^https://.*\.vercel\.app$", |
89 | 73 | ] |
90 | 74 |
|
91 | | -# CSRF security for POST requests from cross-origin domains |
| 75 | +# CSRF Trust for new domain |
92 | 76 | CSRF_TRUSTED_ORIGINS = [ |
93 | | - "https://hrms-lite-frontend.vercel.app", |
94 | 77 | "https://hrms-lite-version.netlify.app", |
95 | 78 | ] |
96 | 79 |
|
97 | | -# Password validation |
| 80 | +# Remove strict list if using ALLOW_ALL, but keep Netlify for verification |
| 81 | +CORS_ALLOWED_ORIGINS = [ |
| 82 | + "https://hrms-lite-version.netlify.app", |
| 83 | +] |
| 84 | + |
| 85 | +# --- END CORS --- |
| 86 | + |
98 | 87 | AUTH_PASSWORD_VALIDATORS = [ |
99 | 88 | {'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator'}, |
100 | 89 | {'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator'}, |
101 | 90 | {'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator'}, |
102 | 91 | {'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator'}, |
103 | 92 | ] |
104 | 93 |
|
105 | | -# Internationalization |
106 | 94 | LANGUAGE_CODE = 'en-us' |
107 | 95 | TIME_ZONE = 'UTC' |
108 | 96 | USE_I18N = True |
109 | 97 | USE_TZ = True |
110 | 98 |
|
111 | | -# Static files (CSS, JavaScript, Images) |
112 | 99 | STATIC_URL = '/static/' |
113 | 100 | STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles') |
114 | 101 | STATICFILES_STORAGE = 'whitenoise.storage.CompressedManifestStaticFilesStorage' |
0 commit comments