-
Notifications
You must be signed in to change notification settings - Fork 1
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 (#12)
The main goal of this PR is in the first commit: ## 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)"} ``` ## Other changes - Make sure to return correct content-type when JSON errors are returned - Refactoring of the test file to clarify the context / stubs
- Loading branch information
Showing
2 changed files
with
101 additions
and
72 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters