So I using cakephp and using ajax to submit forms. In some cases it returns a custom error.
For example, at one point it can be like:
Failed to load resource: the server responded with a status of 412
([{"field":"PaymentCardholderName","message":"Please enter CardHolder's Name."},
{"field":"PaymentCardNumber","message":"Please enter Card Number."},
{"field":"PaymentCvvNumber","message":"Please enter CVV Number."},
{"field":"PaymentBillingAddress","message":"Please enter your Billing Address"}])
Here is the server logic in case anyone needs it
header('HTTP/1.1 412 ' . json_encode($error));
when I open this up locally I see my custom error message. When I deploy it to a remote server I just see my custom error message overwritten
Failed to load resource: the server responded with a status of 412
(Precondition Failed)
It must be some configuration, but I can’t find it.
Additionally, instead of presuming
HTTP/1.1Do this:
Instead of this:
Why? Because
$_SERVER["SERVER_PROTOCOL"]gives you eitherHTTP/1.1orHTTP/1.0based on your browser. If you use the wrong one, apache might add unexpected content to the response. eg. a 4 digit hex code at the start (checksum?), and a trailing zero.