Skip to content


Missing header returns undefined as typeof string #1152

Tivoli opened this Issue · 5 comments

4 participants


express v3.0.0alpha4

In a route using req.get(field) if the field doesn't exist it will return the string 'undefined' instead of undefined.

@tj tj closed this in 685eec0
tj commented

looks fine to me


req.get('Something-Else') does work correctly, I narrowed it down, req.get('X-AppID') fails, any other X-* header field works correctly as does any other header field name I've tested.


Completely unrelated: What's up tivs?!



Actually never mind, it was an error on my side, sorry for the false report.


Here's what I ran into:

  'Expires': getExpires(),

res.get('Expires')  // "undefined"

function getExpires() {
  // ...failed to get an expires time...
  return undefined;

When you set a header value of undefined, it looks like Express casts it to the string "undefined". This kind of feels like funky behavior on the part of Express -- I might expect that setting a header value of undefined would just not set that header.

Anyways, hope this helps someone.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.