Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
errors: add a catch-all handler to give feedback to the proxy user
This generic error handler helps to give context in case of target server errors. Indeed without this commit, the user of the proxy would see a `500 Internal server error`. Now, with the current change the real error is catched and a 502 HTTP error is responded to the user, with some details in a json object `{error: error.message}`. E.g. when targeting a server which has a bad SSL certificate, the user will now receive this response: ``` HTTP/1.1 502 Bad Gateway access-control-allow-origin: * access-control-allow-methods: OPTIONS access-control-allow-methods: GET access-control-allow-methods: POST access-control-allow-methods: PUT access-control-allow-methods: PATCH access-control-allow-methods: DELETE access-control-allow-headers: Content-Type, Authorization, x-bump-proxy-token, x-requested-with content-type: application/json x-content-type-options: nosniff Content-Length: 127 {"error":"SSL_connect returned=1 errno=0 peeraddr=212.95.74.75:443 state=error: certificate verify failed (hostname mismatch)"} ```
- Loading branch information