From 952d15b6ca250ac1d5eb4bd9746ac0fb79e49fc9 Mon Sep 17 00:00:00 2001 From: Nils Pukropp Date: Mon, 16 Feb 2026 17:41:06 +0100 Subject: [PATCH] updated routing --- backend/holy_backend/urls.py | 3 ++- docker-compose.yml | 8 ++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/backend/holy_backend/urls.py b/backend/holy_backend/urls.py index a21f7b1..8887db5 100644 --- a/backend/holy_backend/urls.py +++ b/backend/holy_backend/urls.py @@ -7,10 +7,11 @@ from django.conf.urls.static import static from django.views.static import serve import os -# Ensure the admin path is clean and always ends with a slash for Django +# Clean the admin path admin_url = os.environ.get('ADMIN_URL', 'admin').strip('/') urlpatterns = [ + # Ensure admin ends with a slash for Django's redirection logic path(f'{admin_url}/', admin.site.urls), path('api/', include('api.urls')), path('api/token/', obtain_auth_token, name='api_token'), diff --git a/docker-compose.yml b/docker-compose.yml index d939e66..29c2950 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -20,9 +20,9 @@ services: labels: - "traefik.enable=true" - "traefik.docker.network=narl" - # Explicitly capture specific paths for the backend + # High priority for the backend specific paths - "traefik.http.routers.holy-backend.priority=20" - - "traefik.http.routers.holy-backend.rule=Host(`holy.narl.io`) && (PathPrefix(`/api`)||PathPrefix(`/admin`)||PathPrefix(`/static`)||PathPrefix(`/media`))" + - "traefik.http.routers.holy-backend.rule=Host(`holy.narl.io`) && PathPrefix(`/api`, `/admin`, `/static`, `/media`)" - "traefik.http.routers.holy-backend.entrypoints=websecure" - "traefik.http.routers.holy-backend.tls.certresolver=https_resolver" - "traefik.http.services.holy-backend.loadbalancer.server.port=8000" @@ -42,9 +42,9 @@ services: labels: - "traefik.enable=true" - "traefik.docker.network=narl" - # Frontend ONLY matches if it's NOT a backend path + # Low priority acts as the fallback catch-all - "traefik.http.routers.holy-frontend.priority=10" - - "traefik.http.routers.holy-frontend.rule=Host(`holy.narl.io`) && ! (PathPrefix(`/api`)||PathPrefix(`/admin`)||PathPrefix(`/static`)||PathPrefix(`/media`))" + - "traefik.http.routers.holy-frontend.rule=Host(`holy.narl.io`)" - "traefik.http.routers.holy-frontend.entrypoints=websecure" - "traefik.http.routers.holy-frontend.tls.certresolver=https_resolver" - "traefik.http.services.holy-frontend.loadbalancer.server.port=80"