mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-02-28 01:21:13 +01:00
fix: #11600, prevent helmet crash on startup
This commit is contained in:
@@ -199,13 +199,17 @@ function setupHelmet(app) {
|
|||||||
}
|
}
|
||||||
if (meta.config['hsts-enabled']) {
|
if (meta.config['hsts-enabled']) {
|
||||||
options.hsts = {
|
options.hsts = {
|
||||||
maxAge: meta.config['hsts-maxage'],
|
maxAge: Math.max(0, meta.config['hsts-maxage']),
|
||||||
includeSubDomains: !!meta.config['hsts-subdomains'],
|
includeSubDomains: !!meta.config['hsts-subdomains'],
|
||||||
preload: !!meta.config['hsts-preload'],
|
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}`);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user