framework icon indicating copy to clipboard operation
framework copied to clipboard

[Proposal] Consider HTTP Accept header when returning exceptions/error

Open stefanneubig opened this issue 13 years ago • 0 comments

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?

stefanneubig avatar May 13 '13 13:05 stefanneubig