From 41abdf407413d683c7ba2fa9e4ba52b61dbd2107 Mon Sep 17 00:00:00 2001 From: Keith Smith Date: Fri, 26 Dec 2025 22:13:07 -0700 Subject: [PATCH] Add debug endpoint to check mobile app User-Agent --- config/urls.py | 4 ++++ tasks/views_debug.py | 20 ++++++++++++++++++++ 2 files changed, 24 insertions(+) create mode 100644 tasks/views_debug.py diff --git a/config/urls.py b/config/urls.py index 1090be3..d61560b 100644 --- a/config/urls.py +++ b/config/urls.py @@ -11,12 +11,16 @@ from users.urls import api_urlpatterns as users_api_urls, web_urlpatterns as use from tasks.urls import api_urlpatterns as tasks_api_urls, web_urlpatterns as tasks_web_urls from sync.urls import api_urlpatterns as sync_api_urls from notifications.urls import api_urlpatterns as notifications_api_urls +from tasks.views_debug import debug_user_agent from .views import api_root urlpatterns = [ # Admin path('admin/', admin.site.urls), + # Debug endpoint (remove in production) + path('debug/user-agent/', debug_user_agent, name='debug-user-agent'), + # API root path('api/', api_root, name='api-root'), diff --git a/tasks/views_debug.py b/tasks/views_debug.py new file mode 100644 index 0000000..be9ff61 --- /dev/null +++ b/tasks/views_debug.py @@ -0,0 +1,20 @@ +"""Debug views for troubleshooting mobile app.""" + +from django.http import JsonResponse +from django.views.decorators.csrf import csrf_exempt + + +@csrf_exempt +def debug_user_agent(request): + """Return the User-Agent header for debugging mobile app.""" + user_agent = request.META.get('HTTP_USER_AGENT', 'No User-Agent') + + return JsonResponse({ + 'user_agent': user_agent, + 'is_mobile_app_detected': ( + 'CapacitorHttp' in user_agent or + 'com.firebugit.keepitgoing' in user_agent or + ('KeepItGoing' in user_agent and 'Mobile' in user_agent) + ), + 'headers': dict(request.META), + })