-
Notifications
You must be signed in to change notification settings - Fork 259
nginx and haproxy should respect Accept
headers when responding with error templates
#8179
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
The suspense is killing me! |
Apologies. Resuscitation in progress. |
Also noting that the lack of a proper JSON and sending HTML instead affects more tickets than the two above. Spot checking one, I found: "This indicates that CouhchDb is down and Haproxy responds with html instead of JSON" #7759. A fix to this will be a welcome addition! |
We have suggested that HAProxy error pages to be JSON only since HAProxy is not externally available |
What feature do you want to improve?
Both nginx and haproxy use the default error templates for 4xx and 5xx responses. These templates are html.
Respecting the
Accept
header would standardize the behavior of the CHT, and this is important since we expect third party software to call CHT APIs.To reproduce:
docker stop <api container name>
curl -k https://localhost -H 'Accept: application/json'
If you are logged into webapp, you will see a JSON parse error spammed in the console:

Describe the improvement you'd like
We should change nginx and haproxy configs to respond with JSON when the
Accept: application/json
header is passed.Describe alternatives you've considered
Leave it as it is.
Additional context
I had a script that passed the result of an API call to
jq
. Because the response was html, myjq
call failed.Similarly, we've seen reports of feedback docs being generated that feedback docs get generated in webapp when with
Unexpected token < in JSON at position 0
:#6412
#7782
The text was updated successfully, but these errors were encountered: