Return JSON for 404 error instead of html

B.R. reallfqq-nginx at yahoo.fr
Tue May 13 19:15:16 UTC 2014


I understand the logic, but when using that handler through error_page 404
@404, won't the handler's 200 status overload the original 404 one?

---
*B. R.*


On Tue, May 13, 2014 at 4:37 PM, Valentin V. Bartenev <vbart at nginx.com>wrote:

> On Tuesday 13 May 2014 15:30:56 B.R. wrote:
> > > Instead of using 3rd-party echo module, you can utilize the return
> > > directive
> > >
> > > for the same purpose:
> > >   return 200 '{"status": "Not Found"}';
> > >
> > > Reference: http://nginx.org/r/return
> > >
> > >   wbr, Valentin V. Bartenev
> >
> > ​I would have intuitively written code 404 rather than 200 on this one
> > since the aim is to send a 404 error answer.​
> > Am I wrong? Would that loop?
> >
>
> I wrote an equivalent of "echo".  The logic is that in this handler we
> provide
> the page for 404 which actually exists.
>
>    wbr, Valentin V. Bartenev
>
> _______________________________________________
> nginx mailing list
> nginx at nginx.org
> http://mailman.nginx.org/mailman/listinfo/nginx
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.nginx.org/pipermail/nginx/attachments/20140513/04bb11a3/attachment.html>


More information about the nginx mailing list