Browse Source

feat(backend): configure Django to serve compiled React SPA from frontend/dist

master
PouyaKhajavi 2 days ago
parent
commit
b9fe9ae896
  1. 5
      backend/config/settings.py
  2. 2
      backend/config/urls.py
  3. 1
      frontend/vite.config.js

5
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

2
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')),

1
frontend/vite.config.js

@ -8,6 +8,7 @@ export default defineConfig({
react(),
tailwindcss(),
],
base: '/static/',
server: {
proxy: {
'/api': {

Loading…
Cancel
Save