helmetjs/hsts

Improve `setIf` documentation

EvanHahn opened this issue · 0 comments

To quote @frodsan in #8:

Also, the setIf example could be improved with a more real use case, for example, using this library in a proxy-setup (like heroku):

 hsts: {
     // ...
     setIf: (req) => req.secure || (req.headers["x-forwarded-proto"] === "https"),
   },

This is a good idea. I'd like to use ES5 in the code samples, so maybe something like this:

setIf: function (req) {
  return req.secure || (req.headers['x-forwarded-proto'] === 'https')
}

If someone wants to take a stab at this, feel free! If not, I'll take a look at it when I can.