log invalid api requests

This commit is contained in:
j 2024-11-07 14:28:28 +00:00
parent 03daede441
commit a24d96b098

View file

@ -34,6 +34,13 @@ def api(request):
return response return response
if request.META.get('CONTENT_TYPE') == 'application/json': if request.META.get('CONTENT_TYPE') == 'application/json':
r = json.loads(request.body.decode('utf-8')) r = json.loads(request.body.decode('utf-8'))
if 'action' not in r:
logger.error("invalid api request: %s", r)
response = render_to_json_response(json_response(status=400,
text='Invalid request'))
response['Access-Control-Allow-Origin'] = '*'
return response
else:
action = r['action'] action = r['action']
data = r.get('data', {}) data = r.get('data', {})
else: else: