diff --git a/ara/settings/dev/__init__.py b/ara/settings/dev/__init__.py index c5ce02f2..232ed794 100644 --- a/ara/settings/dev/__init__.py +++ b/ara/settings/dev/__init__.py @@ -1,3 +1,4 @@ +import socket from datetime import datetime, timezone from ara.settings import INSTALLED_APPS, LOGGING, MIDDLEWARE @@ -12,7 +13,7 @@ "http://localhost", ] -CORS_ORIGIN_ALLOW_ALL = True +CORS_ALLOW_ALL_ORIGINS = True SSO_IS_BETA = False @@ -29,6 +30,18 @@ "debug_toolbar_force.middleware.ForceDebugToolbarMiddleware", ] +# https://django-debug-toolbar.readthedocs.io/ + +_, _, ips = socket.gethostbyname_ex(socket.gethostname()) +INTERNAL_IPS = [ip[: ip.rfind(".")] + ".1" for ip in ips] + [ + "127.0.0.1", + "10.0.2.2", +] + +DEBUG_TOOLBAR_CONFIG = { + "SHOW_TOOLBAR_CALLBACK": lambda _: True, +} + REST_FRAMEWORK["DEFAULT_AUTHENTICATION_CLASSES"] = ( "rest_framework.authentication.BasicAuthentication", "ara.authentication.CsrfExemptSessionAuthentication", diff --git a/ara/settings/django.py b/ara/settings/django.py index d6772dc3..49409645 100644 --- a/ara/settings/django.py +++ b/ara/settings/django.py @@ -118,15 +118,8 @@ STATIC_URL = "/static/" - -# https://django-debug-toolbar.readthedocs.io/ - INTERNAL_IPS = ("127.0.0.1",) -if env("DJANGO_ENV") == "development": - INTERNAL_IPS = type(str("c"), (), {"__contains__": lambda *a: True})() - - SESSION_ENGINE = "django.contrib.sessions.backends.db" SESSION_COOKIE_HTTPONLY = True SESSION_COOKIE_SECURE = True diff --git a/ara/settings/test.py b/ara/settings/test.py index ff688063..31310c31 100644 --- a/ara/settings/test.py +++ b/ara/settings/test.py @@ -28,3 +28,7 @@ CELERY_TASK_ALWAYS_EAGER = True ELASTICSEARCH_INDEX_NAME = "articles_test" + +DEBUG_TOOLBAR_CONFIG = { + "SHOW_TOOLBAR_CALLBACK": lambda _: False, +} diff --git a/ara/urls.py b/ara/urls.py index ea27cf64..50e0990a 100644 --- a/ara/urls.py +++ b/ara/urls.py @@ -39,10 +39,7 @@ ), ] -# installed apps (test environment) if settings.DEBUG: - import debug_toolbar - urlpatterns += [ - path("__debug__/", include(debug_toolbar.urls)), + path("api/__debug__/", include("debug_toolbar.urls")), ]