Skip to content

Add res.json(...) support - /w work around #39

@bpetty-formfast

Description

@bpetty-formfast

Almost all of my controllers return res.json(...).
run-middleware does not appear to correctly support this.

In express/lib/response.js it tries to see if Content-Type is set as a header, eventually through the getHeader(...) call.
getHeader is implemented a little poorly, expecting "this[kOutHeaders]" to equal null, but instead it is undefined.

That means all res.json(...) calls will fail. I haven't looked at your code, but is your response not extending OutgoingMessage ?

As a workaround, after I did runMiddleware(app), I added this little gem:

app.response.getHeader = (name) => { 
    return null; 
};`

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions