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

Map response headers #37

Open
ighunter opened this issue Nov 7, 2022 · 0 comments
Open

Map response headers #37

ighunter opened this issue Nov 7, 2022 · 0 comments

Comments

@ighunter
Copy link

ighunter commented Nov 7, 2022

There are cases where I would like to set additional headers on a problem details response. For example:

For now this is my workaround, which relies on the errors thrown or passed to next having a valid headers property, and feels a bit hacky:

app.use((err, req, res, next) => {
  if (err.headers && (typeof err.headers === 'object')) {
    for (let [key, val] of Object.entries(err.headers)) {
      res.header(key, val);
    }
  }
  next(err);
});

app.use(HttpProblemResponse({strategy}));

I think it would be better if we could somehow explicitly include response headers when mapping specific error types, such that those headers are then set on the response sent by HttpProblemDetailsMiddleware().

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

1 participant