I am using heroku-buildpack-elixir to deploy an application to Heroku. My application consists of a simple Plug/Cowboy setup. I noticed that when unhandled exceptions occur, a nice error message appears, showing the stack trace and the lines of code where the error appeared.
This is ok for development environments, however on production environments I do not want my code to be visible to visitors. How can I disable or override the default behaviour?
I tried setting the MIX_ENV
environment variable to prod
in Heroku with no effect.
wrap the Plug.Debugger statement in an if clause. Running in prod environment no longer show errors as html pages. source
if Mix.env == :dev do
use Plug.Debugger, otp_app: :my_app
end