Skip to content

Commit 711620d

Browse files
committed
deployment issue
1 parent dce8868 commit 711620d

2 files changed

Lines changed: 15 additions & 27 deletions

File tree

backend/attendance/urls.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
from .views import AttendanceMarkView, AttendanceListView, AttendanceSummaryView, AttendanceByDateView
33

44
urlpatterns = [
5+
# Supporting both but prioritizing slash-less as per user request
56
path('mark', AttendanceMarkView.as_view(), name='attendance-mark'),
67
path('by-date', AttendanceByDateView.as_view(), name='attendance-by-date'),
78
path('employee/<str:employee_id>', AttendanceListView.as_view(), name='attendance-list'),

backend/core/settings.py

Lines changed: 14 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,12 @@
88

99
load_dotenv()
1010

11-
# Build paths inside the project like this: BASE_DIR / 'subdir'.
1211
BASE_DIR = Path(__file__).resolve().parent.parent
1312

14-
# SECURITY WARNING: keep the secret key used in production secret!
1513
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!
1814
DEBUG = os.getenv('DEBUG', 'True') == 'True'
19-
2015
ALLOWED_HOSTS = os.getenv('ALLOWED_HOSTS', '').split(',') if os.getenv('ALLOWED_HOSTS') else ['*']
2116

22-
# Application definition
2317
INSTALLED_APPS = [
2418
'django.contrib.admin',
2519
'django.contrib.auth',
@@ -35,7 +29,7 @@
3529
]
3630

3731
MIDDLEWARE = [
38-
'corsheaders.middleware.CorsMiddleware', # Preflight and CORS must be FIRST
32+
'corsheaders.middleware.CorsMiddleware', # MUST BE FIRST
3933
'django.middleware.security.SecurityMiddleware',
4034
'whitenoise.middleware.WhiteNoiseMiddleware',
4135
'django.contrib.sessions.middleware.SessionMiddleware',
@@ -48,9 +42,10 @@
4842

4943
ROOT_URLCONF = 'core.urls'
5044

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
5449

5550
TEMPLATES = [
5651
{
@@ -68,47 +63,39 @@
6863
]
6964

7065
WSGI_APPLICATION = 'core.wsgi.application'
71-
72-
# Database
7366
DATABASES = {}
7467

75-
# CORS settings - Bulletproof for Netlify migration
68+
# --- BULLETPROOF CORS CONFIG ---
7669
CORS_ALLOW_ALL_ORIGINS = True
77-
CORS_ORIGIN_ALLOW_ALL = True # Legacy compatibility
7870
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-
8671
CORS_ALLOWED_ORIGIN_REGEXES = [
8772
r"^https://.*\.netlify\.app$",
88-
r"^https://.*\.vercel\.app$",
8973
]
9074

91-
# CSRF security for POST requests from cross-origin domains
75+
# CSRF Trust for new domain
9276
CSRF_TRUSTED_ORIGINS = [
93-
"https://hrms-lite-frontend.vercel.app",
9477
"https://hrms-lite-version.netlify.app",
9578
]
9679

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+
9887
AUTH_PASSWORD_VALIDATORS = [
9988
{'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator'},
10089
{'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator'},
10190
{'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator'},
10291
{'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator'},
10392
]
10493

105-
# Internationalization
10694
LANGUAGE_CODE = 'en-us'
10795
TIME_ZONE = 'UTC'
10896
USE_I18N = True
10997
USE_TZ = True
11098

111-
# Static files (CSS, JavaScript, Images)
11299
STATIC_URL = '/static/'
113100
STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles')
114101
STATICFILES_STORAGE = 'whitenoise.storage.CompressedManifestStaticFilesStorage'

0 commit comments

Comments
 (0)