|
40 | 40 |
|
41 | 41 | 'corsheaders', |
42 | 42 | 'rest_framework', |
43 | | - 'rest_framework.authtoken', # Add this for token authentication |
| 43 | + 'rest_framework.authtoken', |
44 | 44 | 'giraph', |
45 | 45 | 'users', |
46 | 46 | 'programs', |
47 | 47 | 'outcomes', |
48 | 48 | ] |
49 | 49 |
|
50 | 50 | MIDDLEWARE = [ |
| 51 | + 'corsheaders.middleware.CorsMiddleware', # Must be first |
51 | 52 | 'django.middleware.security.SecurityMiddleware', |
52 | 53 | 'django.contrib.sessions.middleware.SessionMiddleware', |
53 | | - 'corsheaders.middleware.CorsMiddleware', |
54 | 54 | 'django.middleware.common.CommonMiddleware', |
55 | 55 | 'django.middleware.csrf.CsrfViewMiddleware', |
56 | 56 | 'django.contrib.auth.middleware.AuthenticationMiddleware', |
|
60 | 60 |
|
61 | 61 | ROOT_URLCONF = 'backend.urls' |
62 | 62 |
|
| 63 | +REST_FRAMEWORK = { |
| 64 | + 'DEFAULT_AUTHENTICATION_CLASSES': [ |
| 65 | + 'rest_framework.authentication.TokenAuthentication', |
| 66 | + 'rest_framework.authentication.SessionAuthentication', |
| 67 | + ], |
| 68 | + 'DEFAULT_PERMISSION_CLASSES': [ |
| 69 | + 'rest_framework.permissions.IsAuthenticated', |
| 70 | + ], |
| 71 | +} |
| 72 | + |
| 73 | +# CORS settings |
63 | 74 | CORS_ALLOWED_ORIGINS = [ |
64 | 75 | "http://localhost:3000", |
| 76 | + "http://127.0.0.1:3000", |
| 77 | + "http://localhost:3001", |
| 78 | + "http://127.0.0.1:3001", |
| 79 | +] |
| 80 | + |
| 81 | +CORS_ALLOW_CREDENTIALS = True |
| 82 | + |
| 83 | +CORS_ALLOW_HEADERS = [ |
| 84 | + 'accept', |
| 85 | + 'accept-encoding', |
| 86 | + 'authorization', |
| 87 | + 'content-type', |
| 88 | + 'dnt', |
| 89 | + 'origin', |
| 90 | + 'user-agent', |
| 91 | + 'x-csrftoken', |
| 92 | + 'x-requested-with', |
65 | 93 | ] |
66 | 94 |
|
67 | 95 | # Add custom user model |
|
72 | 100 | 'django.contrib.auth.backends.ModelBackend', |
73 | 101 | ] |
74 | 102 |
|
75 | | -# Add REST Framework configuration |
76 | | -REST_FRAMEWORK = { |
77 | | - 'DEFAULT_AUTHENTICATION_CLASSES': [ |
78 | | - 'rest_framework.authentication.TokenAuthentication', |
79 | | - 'rest_framework.authentication.SessionAuthentication', |
80 | | - ], |
81 | | - 'DEFAULT_PERMISSION_CLASSES': [ |
82 | | - 'rest_framework.permissions.AllowAny', # Change to IsAuthenticated later |
83 | | - ], |
84 | | -} |
85 | | - |
86 | 103 | TEMPLATES = [ |
87 | 104 | { |
88 | 105 | 'BACKEND': 'django.template.backends.django.DjangoTemplates', |
|
153 | 170 | # https://docs.djangoproject.com/en/5.2/ref/settings/#default-auto-field |
154 | 171 |
|
155 | 172 | DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField' |
| 173 | + |
| 174 | +# Email Configuration for Gmail |
| 175 | +EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend' |
| 176 | +EMAIL_HOST = 'smtp.gmail.com' |
| 177 | +EMAIL_PORT = 587 |
| 178 | +EMAIL_USE_TLS = True |
| 179 | +EMAIL_HOST_USER = '[email protected]' |
| 180 | +###EMAIL_HOST_PASSWORD = |
| 181 | +DEFAULT_FROM_EMAIL = '[email protected]' |
0 commit comments