Fix delete JSON error: API routes return 401 JSON instead of HTML redirect, robust fetch error handling

This commit is contained in:
eric 2026-02-23 08:58:18 +00:00
parent 58fcddbff1
commit 7844e82c95
2 changed files with 12 additions and 1 deletions

3
app.py
View file

@ -438,6 +438,9 @@ def login_required(f):
@wraps(f)
def decorated_function(*args, **kwargs):
if not session.get('authenticated'):
# API-Routen (/api/...) geben JSON zurück statt HTML-Redirect
if request.path.startswith('/api/'):
return jsonify({'success': False, 'error': 'not_authenticated'}), 401
return redirect(url_for('login'))
return f(*args, **kwargs)
return decorated_function