Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to disable "stack trace" in errors outputs? #18

Closed
mindonline opened this issue Sep 11, 2017 · 2 comments
Closed

How to disable "stack trace" in errors outputs? #18

mindonline opened this issue Sep 11, 2017 · 2 comments

Comments

@mindonline
Copy link

How to disable this output due to security issues on raised errors like 404 ?
I didn't saw any ways to overcome ODataErrorHandler behavior.

@mindonline mindonline changed the title How to disable "stack" trace on errors outputs? How to disable "stack trace" in errors outputs? Sep 11, 2017
@mindonline
Copy link
Author

Please, consider pull request. #19
Also, may be some one helps, as intermediate solution I found this:

// Custom error handler
function ODataErrorHandler(err, _, res, next){
    .....
}

/// YOUR DECORATORS HERE
export class NorthwindServer extends ODataServer{
    ....
	static oldRequestHandlerRes;
	
	static requestHandler(){
		this.oldRequestHandlerRes = super.requestHandler();		
		return (req:express.Request, res:express.Response, next:express.NextFunction) => {
			return next();
		}
	}
}

const app = express();
app.use(
    NorthwindServer.create(),
    NorthwindServer.oldRequestHandlerRes,
    ODataErrorHandler
);
app.listen(3000);

lazarv added a commit that referenced this issue Mar 5, 2018
@lazarv
Copy link
Contributor

lazarv commented Mar 5, 2018

Hi @mindonline,
using [email protected] you can define custom error request handler, see example here: https://github.com/jaystack/odata-v4-server/blob/master/src/example/advanced.ts#L84
and you can define the ODATA_V4_DISABLE_STACKTRACE environment variable to disable stacktrace using the default ODataErrorHandler.

@lazarv lazarv closed this as completed Mar 5, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants