From ca0e496b48489ca1b4c24f73fde6f4fb00cd0752 Mon Sep 17 00:00:00 2001 From: syuilo Date: Sat, 7 Jan 2017 23:57:45 +0900 Subject: [PATCH] [Server] Fix bug Reject request that without 'Host' header --- src/server.ts | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/server.ts b/src/server.ts index e9bc07a7f..421ad60c1 100644 --- a/src/server.ts +++ b/src/server.ts @@ -14,6 +14,15 @@ import vhost = require('vhost'); const app = express(); app.disable('x-powered-by'); +// Reject request that without 'Host' header +app.use((req, res, next) => { + if (!req.headers.host) { + res.sendStatus(400); + } else { + next(); + } +}); + /** * Register modules */