Disable default apache error pages
<p>I am creating an API that is being accessed through apache. My API is designed to return http status error codes when there was an issue with the request. For example if the API consumer sends on invalid date format as a query parameter the API server will respond with something like this.</p>

<p>Http Status Code: 400<br>
Body:</p>

<pre><code>{
   message: "Invalid date format"
}
</code></pre>

<p>However apache seems to be replacing the body with this error page:</p>

<pre><code>&lt;!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"&gt;
&lt;html&gt;&lt;head&gt;
&lt;title&gt;400 Bad Request&lt;/title&gt;
&lt;/head&gt;&lt;body&gt;
&lt;h1&gt;Bad Request&lt;/h1&gt;
&lt;p&gt;Your browser sent a request that this server could not understand.&lt;br /&gt;
&lt;/p&gt;
&lt;/body&gt;&lt;/html&gt;
</code></pre>

<p>How can I prevent apache from replacing the response?</p>

<p>Note: If the Http Status Code is set to 200 by the API the reponse body returns as expected.</p>

<p>Adding more context: It is an angular app served from apache, that proxies to tomcat for api requests, and the client should handle the error messages instead of serving a static page from apache.</p>