I have front-end Angular running on Apache with back-end Spring REST API on Tomcat.
I wanted to throw 501 error in some error case and want that response to be presented as JSON to UI (Content-Type
as "application/json"
). This works fine in my local as expected with Angular is able to interpret the JSON response but when it comes to some common QA environment it fails because the 501 error presented to UI as text/html which Angular can't digest.
Difference between my local and QA is, Angular is running on node whereas QA uses Apache. Is the apache who is converting JSON response with 501 http code to html type?
the response i get on my browser is below.
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>501 Not Implemented</title>
</head><body>
<h1>Not Implemented</h1>
<p>GET to /test/customer/getCustomer not supported.<br />
</p>
</body></html>