How to fix broken API responses with Apache proxy
I've been stuck on this for a while and I have difficulties looking for a solution.
I have an application that calls an api and it was hosted in a docker and a reverse proxy in apache.
I noticed that every time I request to any of my apis, I always get weird behaviour like the actual error message (which is in json format) are not being displayed.
After a long investigation, I noticed that the api that returns an error (e.g.: 400, 401, etc..) always returns html error message/page.
If you are like me, hope you find this š
Just add this line:
<If "%{HTTP_ACCEPT} =~ /json/">
ProxyErrorOverride Off
</If>
In your apache vhost config.