fix: #11600, prevent helmet crash on startup

This commit is contained in:
Barış Soner Uşaklı
2023-05-13 15:16:36 -04:00
parent 412a1ecf93
commit 8eed5a8413

View File

@@ -199,13 +199,17 @@ function setupHelmet(app) {
}
if (meta.config['hsts-enabled']) {
options.hsts = {
maxAge: meta.config['hsts-maxage'],
maxAge: Math.max(0, meta.config['hsts-maxage']),
includeSubDomains: !!meta.config['hsts-subdomains'],
preload: !!meta.config['hsts-preload'],
};
}
app.use(helmet(options));
try {
app.use(helmet(options));
} catch (err) {
winston.error(`[startup] unable to initialize helmet \n${err.stack}`);
}
}