Skip to content

Commit 02ec58e

Browse files
authored
Merge pull request sagarkarira#48 from XhmikosR/helmet
Add helmet
2 parents 5fcc6df + 63ac313 commit 02ec58e

File tree

3 files changed

+153
-0
lines changed

3 files changed

+153
-0
lines changed

app.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
const express = require('express');
2+
const helmet = require('helmet');
23
const morgan = require('morgan');
34
const chalk = require('chalk');
45

@@ -27,6 +28,22 @@ function errorHandler(error, res) {
2728

2829
app.set('json escape', true);
2930

31+
app.use(helmet({
32+
dnsPrefetchControl: false,
33+
frameguard: {
34+
action: 'deny'
35+
}
36+
}));
37+
38+
app.use(helmet.hsts({
39+
force: true,
40+
includeSubDomains: true,
41+
maxAge: 63072000, // 2 years
42+
preload: true
43+
}));
44+
45+
app.use(helmet.referrerPolicy({ policy: 'strict-origin-when-cross-origin' }));
46+
3047
app.use(morgan(':remote-addr :remote-user :method :url :status :res[content-length] - :response-time ms'));
3148
app.use((req, res, next) => {
3249
res.setHeader('Cache-Control', 'no-cache');

package-lock.json

Lines changed: 135 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
"country-code-lookup": "0.0.16",
3939
"emoji-flags": "^1.2.0",
4040
"express": "^4.17.1",
41+
"helmet": "^3.21.3",
4142
"humanize-number": "0.0.2",
4243
"lodash": "^4.17.15",
4344
"moment": "^2.24.0",

0 commit comments

Comments
 (0)