♻️(back) stop returning a 500 on cors_proxy on request failure

On the cors_proxy endpoint, if the fetched url fails we were returning
an error 500. Instead, we log the exception and return a 400 to not
give back information to the frontend application.
This commit is contained in:
Manuel Raynaud
2025-08-25 17:24:57 +02:00
parent 247550fc13
commit 586825aafa
2 changed files with 22 additions and 4 deletions

View File

@@ -1481,10 +1481,10 @@ class DocumentViewSet(
return proxy_response
except requests.RequestException as e:
logger.error("Proxy request failed: %s", str(e))
return drf_response.Response(
{"error": f"Failed to fetch resource: {e!s}"},
status=status.HTTP_500_INTERNAL_SERVER_ERROR,
logger.exception(e)
return drf.response.Response(
{"error": f"Failed to fetch resource from {url}"},
status=status.HTTP_400_BAD_REQUEST,
)