From 0821ead024eb5579b09afd8bb3f62c43a5e54d26 Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Tue, 15 Jun 2021 23:51:37 +1000 Subject: [PATCH] Only provide static redirects if in DEBUG mode --- InvenTree/InvenTree/urls.py | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/InvenTree/InvenTree/urls.py b/InvenTree/InvenTree/urls.py index bce493fb23..bf0838c26c 100644 --- a/InvenTree/InvenTree/urls.py +++ b/InvenTree/InvenTree/urls.py @@ -161,18 +161,20 @@ urlpatterns = [ url(r'^markdownx/', include('markdownx.urls')), ] -# Static file access -urlpatterns += static(settings.STATIC_URL, document_root=settings.STATIC_ROOT) +# Server running in "DEBUG" mode? +if settings.DEBUG: + # Static file access + urlpatterns += static(settings.STATIC_URL, document_root=settings.STATIC_ROOT) -# Media file access -urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) + # Media file access + urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) -# Debug toolbar access (if in DEBUG mode) -if settings.DEBUG and 'debug_toolbar' in settings.INSTALLED_APPS: - import debug_toolbar - urlpatterns = [ - path('__debug/', include(debug_toolbar.urls)), - ] + urlpatterns + # Debug toolbar access (only allowed in DEBUG mode) + if 'debug_toolbar' in settings.INSTALLED_APPS: + import debug_toolbar + urlpatterns = [ + path('__debug/', include(debug_toolbar.urls)), + ] + urlpatterns # Send any unknown URLs to the parts page urlpatterns += [url(r'^.*$', RedirectView.as_view(url='/index/', permanent=False), name='index')]