♻️(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:
@@ -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,
|
||||
)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user