framework
framework copied to clipboard
[Proposal] Consider HTTP Accept header when returning exceptions/error
Right now when building an API and an exception happens Laravel will return a well formatted HTML page.
The only way I can force it to response with JSON fis to use a "X-Requested-With" header. Setting the Accept-Header to "application/json" does not work.
I propose Laravel should consider the "Accept" header and also return JSON in this case.
Also I noticed that the HTTP response code is still 200 in error cases. This should be 500 or even more specific when possible.
What do you think?