From b9fe9ae8960869c6e0cd6edea4d78ece28051f53 Mon Sep 17 00:00:00 2001 From: PouyaKhajavi Date: Sat, 8 Aug 2026 12:17:57 +0330 Subject: [PATCH] feat(backend): configure Django to serve compiled React SPA from frontend/dist --- backend/config/settings.py | 5 ++++- backend/config/urls.py | 2 ++ frontend/vite.config.js | 1 + 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/backend/config/settings.py b/backend/config/settings.py index aa0f560..0103c95 100644 --- a/backend/config/settings.py +++ b/backend/config/settings.py @@ -68,7 +68,7 @@ ROOT_URLCONF = 'config.urls' TEMPLATES = [ { 'BACKEND': 'django.template.backends.django.DjangoTemplates', - 'DIRS': [], + 'DIRS': [BASE_DIR.parent / 'frontend' / 'dist'], 'APP_DIRS': True, 'OPTIONS': { 'context_processors': [ @@ -129,6 +129,9 @@ USE_TZ = True # https://docs.djangoproject.com/en/6.0/howto/static-files/ STATIC_URL = 'static/' +STATICFILES_DIRS = [ + BASE_DIR.parent / 'frontend' / 'dist', +] # Default primary key field type # https://docs.djangoproject.com/en/6.0/ref/settings/#default-auto-field diff --git a/backend/config/urls.py b/backend/config/urls.py index a6e0d7a..6f99a05 100644 --- a/backend/config/urls.py +++ b/backend/config/urls.py @@ -16,9 +16,11 @@ Including another URLconf """ from django.contrib import admin from django.urls import path,include +from django.views.generic import TemplateView from core.views import HealthCheckView urlpatterns = [ + path('', TemplateView.as_view(template_name='index.html'), name='dashboard'), path('admin/', admin.site.urls), path('api/health/', HealthCheckView.as_view(), name='health-check'), path('api/crawlers/', include('crawler.urls')), diff --git a/frontend/vite.config.js b/frontend/vite.config.js index 8e3b92f..d3ccba7 100644 --- a/frontend/vite.config.js +++ b/frontend/vite.config.js @@ -8,6 +8,7 @@ export default defineConfig({ react(), tailwindcss(), ], + base: '/static/', server: { proxy: { '/api': {