I started a phoenix project without using the --no-html option, and now I'm trying to make sure that 404 and 500 errors are displayed as JSON. The project started on Phoenix 1.1.0 and has been upgraded to 1.1.4 .
I changed the file config/config.exs render_errors (under config :my_app, MyApp.Endpoint ) as [view: MyApp.ErrorView, format: "json", accepts: ~w(json)] .
All routes accept JSON, and currently none of them accept HTML.
I modified the web/web.ex file to remove the use of Phoenix.HTML in the view function, and I changed web/views/error_view.ex to render JSON.
However, at this point, 404 and 500 errors still return html.
source share