Skip to content

Map response headers #37

@ighunter

Description

@ighunter

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().

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions