about summary refs log tree commit diff stats
path: root/src
diff options
context:
space:
mode:
authorAlan Pearce2017-06-24 23:39:18 +0200
committerAlan Pearce2017-06-24 23:39:18 +0200
commit6061d1e5b5bdd67ab958c7cedc2f3fe5712e3ea2 (patch)
tree9d67f7da80027799018a6c0042bef203df31665e /src
parentabd28f9633da4ac2f7fbdfd930c11a46b567b105 (diff)
downloadhomestead-6061d1e5b5bdd67ab958c7cedc2f3fe5712e3ea2.tar.lz
homestead-6061d1e5b5bdd67ab958c7cedc2f3fe5712e3ea2.tar.zst
homestead-6061d1e5b5bdd67ab958c7cedc2f3fe5712e3ea2.zip
feat: add some security with helmet
Diffstat (limited to 'src')
-rw-r--r--src/app.js10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/app.js b/src/app.js
index 46ebd2e..fa0d5c2 100644
--- a/src/app.js
+++ b/src/app.js
@@ -3,6 +3,8 @@
 const Koa = require('koa')
 const app = new Koa()
 
+const helmet = require('koa-helmet')
+
 const actions = require('./actions.js')
 
 const config = require('./modules/config.js')
@@ -26,6 +28,14 @@ for (let [term, items] of Posts.taxonomies) {
   )
 }
 
+app.use(
+  helmet({
+    hsts: {
+      setIf: ctx => ctx.secure
+    }
+  })
+)
+
 app.use(router.routes()).use(router.allowedMethods())
 
 app.use(actions.serveFiles)