Skip to content
This repository has been archived by the owner on Dec 6, 2024. It is now read-only.

Commit

Permalink
fix: hsts header (#790)
Browse files Browse the repository at this point in the history
  • Loading branch information
maghirardelli authored Nov 10, 2021
1 parent 0967129 commit 66f79f2
Showing 1 changed file with 10 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,16 @@ function handlerFactory({ registerServices, registerRoutes }) {
// register routes
await registerRoutes(appContext, apiRouter);

// Implement HSTS before any other controller (https://www.maxivanov.io/http-strict-transport-security/)
// max-age = 63072000 which is 1 year
// includeSubDomains to protect subdomains of the site with HSTS as well (recommended)
app.use((req, res, next) => {
if (req.secure) {
res.setHeader('Strict-Transport-Security', 'max-age=63072000; includeSubDomains');
}
next();
});

// setup CORS, compression and body parser
const isDev = settingsService.get('envType') === 'dev';
let allowList = settingsService.optionalObject('corsAllowList', []);
Expand Down

0 comments on commit 66f79f2

Please sign in to comment.