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

Strict-Transport-Security: Remove setIf #232

Closed
EvanHahn opened this issue Mar 10, 2019 · 1 comment
Closed

Strict-Transport-Security: Remove setIf #232

EvanHahn opened this issue Mar 10, 2019 · 1 comment
Assignees

Comments

@EvanHahn
Copy link
Member

setIf has been deprecated and will be removed in hsts@3 and helmet@4.

Luckily, the transition is relatively painless—simply do the conditional yourself.

Old:

app.use(hsts({
  maxAge: 123,
  setIf(req, res) {
    return req.secure
  }
}))

New:

const hstsMiddleware = hsts({
  maxAge: 123
})

app.use((req, res, next) {
  if (req.secure) {
    hstsMiddleware(req, res, next)
  } else {
    next()
  }
})
@EvanHahn EvanHahn self-assigned this Sep 1, 2019
EvanHahn referenced this issue in helmetjs/hsts Sep 1, 2019
EvanHahn referenced this issue in helmetjs/hsts Apr 12, 2020
@EvanHahn EvanHahn transferred this issue from helmetjs/hsts Jul 10, 2020
@EvanHahn EvanHahn mentioned this issue Jul 10, 2020
36 tasks
@EvanHahn EvanHahn changed the title Remove setIf Strict-Transport-Security: Remove setIf Jul 10, 2020
@EvanHahn
Copy link
Member Author

Addressed in 788d69b. To be released in version 4 (see #197).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging a pull request may close this issue.

1 participant