FOSRestBundle icon indicating copy to clipboard operation
FOSRestBundle copied to clipboard

After throwing an Exception, I get X-Debug-Exception in headers...

Open marcu87 opened this issue 4 years ago • 4 comments

Hi there,

I'm using version 3.0 (I also tried with 3.0.2 and had the same problem); I added in my code a throw new \Exception(); and in the Response Headers it adds the X-Debug-Exception and X-Debug-Exception-File.

Here an screenshot of the response.

Anyone knows how to avoid this behaviour? Thanks!

marcu87 avatar Aug 20 '20 15:08 marcu87

These headers are added by the SerializerErrorRenderer when the debug mode is enabled.

xabbuh avatar Aug 20 '20 16:08 xabbuh

These headers are added by the SerializerErrorRenderer when the debug mode is enabled.

How do you disable the debug mode?

Willdogx avatar Aug 20 '20 16:08 Willdogx

How do you disable the debug mode?

Removing Debug::enable(); statement from your front file (index.php).

However, this is only done for dev environment, for production it's not called by default.

yceruto avatar Aug 20 '20 20:08 yceruto

You can either set the showException in the current request to false or disable the debug flag in the kernel. Note that by default the additional header are only sent in the dev environment but not in prod.

xabbuh avatar Aug 21 '20 07:08 xabbuh