Skip to content

Node.js based forum software built for the modern web

fix: #11600, prevent helmet crash on startup

Barış Soner Uşaklı8eed5a841375
diff --git a/src/webserver.js b/src/webserver.js
index c0a1c8e537..55e263486a 100644
--- a/src/webserver.js
+++ b/src/webserver.js
@@ -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}`);
+ }
}