Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to turn off development error messages in Phoenix framework?

Right now I'm getting nice error messages from my Phoenix server:

Nice phoenix error message

However, I'm using Phoenix as an API, and these error messages show up as a large chunk of unreadable html:

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>UndefinedFunctionError at GET /api/v1/sessions/test</title>
    <meta name="viewport" content="width=device-width">
    <style>/*! normalize.css v4.2.0 | MIT License | github.com/necolas/normalize.css */html{font
      ...1300+ lines...

Is there a way to turn this off so my development server spits out JSON error messages instead? Thanks.

like image 811
soundly_typed Avatar asked Nov 05 '25 16:11

soundly_typed


1 Answers

In your config/dev.exs in the web endpoint configuration main section set debug_errors value to false:

config :my_app, MyAppWeb.Endpoint,
  # http: [port: 4000],  # or like
  debug_errors: false,   # ⇐ HERE 
  ...
like image 59
Aleksei Matiushkin Avatar answered Nov 09 '25 04:11

Aleksei Matiushkin



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!