diff --git a/src/app/package.json b/src/app/package.json index 6bc6897..cbb65ed 100644 --- a/src/app/package.json +++ b/src/app/package.json @@ -6,6 +6,7 @@ "scripts": { "dev": "vite --host --port 4321", "build": "tsc && vite build", + "prod": "npm run build && rm -rf ../django/dist && mv -f dist ../django/static", "preview": "vite preview" }, "dependencies": { diff --git a/src/django/requirements.txt b/src/django/requirements.txt index d0a0698..da2d3d5 100644 --- a/src/django/requirements.txt +++ b/src/django/requirements.txt @@ -1,4 +1,5 @@ django==4.2 djangorestframework==3.14.0 djangorestframework-gis==1.0 -psycopg2==2.9.6 \ No newline at end of file +psycopg2==2.9.6 +whitenoise==6.4.0 \ No newline at end of file diff --git a/src/django/thirdplaces/settings.py b/src/django/thirdplaces/settings.py index 4ffc04b..4817350 100644 --- a/src/django/thirdplaces/settings.py +++ b/src/django/thirdplaces/settings.py @@ -46,6 +46,7 @@ MIDDLEWARE = [ "django.middleware.security.SecurityMiddleware", + "whitenoise.middleware.WhiteNoiseMiddleware", "django.contrib.sessions.middleware.SessionMiddleware", "django.middleware.common.CommonMiddleware", "django.middleware.csrf.CsrfViewMiddleware", diff --git a/src/django/thirdplaces/urls.py b/src/django/thirdplaces/urls.py index 4fe9dc1..4a8a88b 100644 --- a/src/django/thirdplaces/urls.py +++ b/src/django/thirdplaces/urls.py @@ -15,9 +15,15 @@ 2. Add a URL to urlpatterns: path('blog/', include('blog.urls')) """ from django.contrib import admin -from django.urls import include, path +from django.urls import include, path, re_path +from django.shortcuts import render + +def render_react(request): + return render(request, "index.html") urlpatterns = [ path("api/", include("api.urls")), path("admin/", admin.site.urls), + re_path(r"^$", render_react), + re_path(r"^(?:.*)/?$", render_react), ]