nginx returns html instead of json response
[email protected] (Kaushal Shriyan)
| Newsgroups | php.general |
|---|---|
| Message-ID | <CAD7Ssm9Y9cQd6ZBpcbrf-=vKnCwbbhX2xENtP+F4cW0abpoDDg@mail.gmail.com> |
Hi,
I have configured the below settings in nginx after a few attempts by
tweaking it.
location /apis {
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
fastcgi_intercept_errors off;
add_header "X-Debug-JSON-APIS" $http_accept always;
fastcgi_pass 127.0.0.1:9000;
include fastcgi.conf;
fastcgi_param SCRIPT_FILENAME $document_root/index.php;
}
I have a follow up question related to the below error which appears in
html instead of JSON format when I hit rest api calls
http://mydomain.com/apis in case of when the MySQL Database service is down
as part of testing the end to end flow. The flow is as follows:
User -> Nginx webserver -> PHP-FPM upstream server -> MySQL Database.
The Website Encountered an Unexpected Error. Please try again Later </br>
Is there a way to display the above string in JSON format?
Please guide me. Thanks in advance.
Best Regards,
Kaushal