From 257ee30fd2f36880baf8d7411df9893c71ad7a33 Mon Sep 17 00:00:00 2001 From: Dries Peeters Date: Tue, 21 Oct 2025 17:29:28 +0200 Subject: [PATCH] Update clients.py --- app/routes/clients.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/app/routes/clients.py b/app/routes/clients.py index c40dc859..64c72e2f 100644 --- a/app/routes/clients.py +++ b/app/routes/clients.py @@ -42,12 +42,23 @@ def list_clients(): @login_required def create_client(): """Create a new client""" - # Detect AJAX/JSON request + # Detect AJAX/JSON request while preserving classic form behavior + try: + # Consider classic HTML forms regardless of Accept header + is_classic_form = request.mimetype in ( + 'application/x-www-form-urlencoded', + 'multipart/form-data' + ) + except Exception: + is_classic_form = False + try: wants_json = ( request.headers.get('X-Requested-With') == 'XMLHttpRequest' or request.is_json - or request.accept_mimetypes['application/json'] >= request.accept_mimetypes['text/html'] + or (not is_classic_form and ( + request.accept_mimetypes['application/json'] > request.accept_mimetypes['text/html'] + )) ) except Exception: wants_json = False