My controller is set @JSONController()
Then I have a method login(@Body({required: true}) user: User)
If I do not specify a user (using Postman as my test client) I get the following JSON returned
{
"name": "ParamRequiredError",
"message": "Request body is required for request on POST /api/auth/login",
"stack": "Error\n at ParamRequiredError.HttpError [as constructor] (E:\\Testing\\server-test\\src\\http-error\\HttpError.ts:19:22)\n at ParamRequiredError.BadRequestError [as constructor] (E:\\Testing\\server-test\\src\\http-error\\BadRequestError.ts:10:9)\n at new ParamRequiredError (E:\\Testing\\server-test\\src\\error\\ParamRequiredError.ts:13:9)\n at ActionParameterHandler.handleValue (E:\\Testing\\server-test\\src\\ActionParameterHandler.ts:78:39)\n at E:\\Testing\\server-test\\src\\ActionParameterHandler.ts:46:45\n at <anonymous>\n at process._tickCallback (internal/process/next_tick.js:169:7)"
}
Obviously I do not want that stack bit showing up in production. How do I remove it? I tried setting NODE_ENV='production' and testing to see if it stil remained, which it did.
How do I remove the stack from JSON and in the console itself in production ?
if (error.stack && this.developmentMode)
processedError.stack = error.stack;
if (options && options.development !== undefined) {
driver.developmentMode = options.development;
} else {
driver.developmentMode = process.env.NODE_ENV !== "production";
}
So the error stack is returned in json only if your NODE_ENV is different than "production".
You can overwrite it by passing development: false in create server options.
@19majkel94 Where do I put the above code ? --(EDIT: That's the lib code isn't it)
If I just set development: false in my useServer call, will this be sufficient ?
If so, then I can check the NODE_ENV and start and set it dynamically.
Where do I put the above code ? --(EDIT: That's the lib code isn't it)
Yeah, I posted the lib code to show you how it works.
If I just set development: false in my useServer call, will this be sufficient ?
If so, then I can check the NODE_ENV and start and set it dynamically.
Right, check if development: false works for you and then you can set it dynamically as you want.
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Most helpful comment
Yeah, I posted the lib code to show you how it works.
Right, check if
development: falseworks for you and then you can set it dynamically as you want.