From 8eb6cc0a7cbb3ad1cdefaec131717597bfe4f02f Mon Sep 17 00:00:00 2001 From: Jake Howard Date: Sat, 6 May 2017 22:59:29 +0100 Subject: [PATCH] remove powered-by header --- src/server.ts | 1 + tests/server.test.ts | 15 +++++++++++++++ 2 files changed, 16 insertions(+) diff --git a/src/server.ts b/src/server.ts index 6753f79..751e214 100644 --- a/src/server.ts +++ b/src/server.ts @@ -15,6 +15,7 @@ import { Options } from './types'; export default function createServer(opts : Options) : express.Application { const app = express(); + app.disable('x-powered-by'); if (process.env.NODE_ENV !== 'test') { app.use(logging); } diff --git a/tests/server.test.ts b/tests/server.test.ts index b4eb395..edbfed4 100644 --- a/tests/server.test.ts +++ b/tests/server.test.ts @@ -20,6 +20,21 @@ describe('Server', function () { }); }); + it('Should nave no x-powered-by header', function (done) { + runServer({ + allowed_ips: [], + basicAuth: [], + dirList: false, + serveDir: 'site/', + opbeat: false, + open: false + }, '/index.html', function (response : any) { + expect(response.status).to.equal(200); + expect(response.headers.get('x-powered-by')).to.equal(null); + done(); + }); + }); + describe('index route', function () { const body = fs.readFileSync(path.join(__dirname, '..', 'site', 'index.html')).toString();