diff --git a/config/express.js b/config/express.js index 418a5b3c..6b5e1b85 100755 --- a/config/express.js +++ b/config/express.js @@ -85,6 +85,16 @@ module.exports = function(db) { app.use(bodyParser.json()); app.use(methodOverride()); + // Use helmet to secure Express headers + app.use(helmet.xframe()); + app.use(helmet.xssFilter()); + app.use(helmet.nosniff()); + app.use(helmet.ienoopen()); + app.disable('x-powered-by'); + + // Setting the app router and static folder + app.use(express.static(path.resolve('./public'))); + // CookieParser should be above session app.use(cookieParser()); @@ -108,16 +118,6 @@ module.exports = function(db) { // connect flash for flash messages app.use(flash()); - // Use helmet to secure Express headers - app.use(helmet.xframe()); - app.use(helmet.xssFilter()); - app.use(helmet.nosniff()); - app.use(helmet.ienoopen()); - app.disable('x-powered-by'); - - // Setting the app router and static folder - app.use(express.static(path.resolve('./public'))); - // Globbing routing files config.getGlobbedFiles('./app/routes/**/*.js').forEach(function(routePath) { require(path.resolve(routePath))(app); @@ -162,4 +162,4 @@ module.exports = function(db) { // Return Express server instance return app; -}; \ No newline at end of file +};