Skip to content
This repository has been archived by the owner on Jan 8, 2023. It is now read-only.

Middleware adds X-Powered-By header #3

Closed
dimitrisfasoulas opened this issue Sep 25, 2019 · 0 comments
Closed

Middleware adds X-Powered-By header #3

dimitrisfasoulas opened this issue Sep 25, 2019 · 0 comments

Comments

@dimitrisfasoulas
Copy link

Using the default example and adding disable('x-power-by') :

const express = require('express');
const promMid = require('express-prometheus-middleware');
const app = express();

const PORT = 9091;
app.disable('x-powered-by');
app.use(promMid({
  metricsPath: '/metrics',
  collectDefaultMetrics: true,
  requestDurationBuckets: [0.1, 0.5, 1, 1.5],
}));

// curl -X GET localhost:9091/hello?name=Chuck%20Norris
app.get('/hello', (req, res) => {
  console.log('GET /hello');
  const { name = 'Anon' } = req.query;
  res.json({ message: `Hello, ${name}!` });
});

app.listen(PORT, () => {
  console.log(`Example api is listening on http://localhost:${PORT}`);
});

then do curl -i http://localhost:9091
you get

X-Powered-By: Express
...```

where if you remove the promMid then the header is removed.
dimitrisfasoulas pushed a commit to dimitrisfasoulas/express-prometheus-middleware that referenced this issue Sep 25, 2019
dimitrisfasoulas pushed a commit to dimitrisfasoulas/express-prometheus-middleware that referenced this issue Sep 27, 2019
Previously, express apps that where consuming the middleware, were including the `X-Powered-By` header on every response, even if the app it self had the header disabled `app.disable('x-powered-by')'.
This commit allows said express app to disable or allow said header.

closes joao-fontenele#3
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant