node.jstypescriptexpressbackendloopbackjs

remove header X-powered-by Express using @types/express


I have to remove X-powered-by Express header, I found theses solution

app.disable('x-powered-by');

or

app.use(function (req, res, next) {
  res.removeHeader("X-Powered-By");
  next();
});

but in this project we don't use express in a basic way, we import Express this way in multiple files

import {Express} from 'express'; // @types/Express

and then we call Express.multer.file

I'm new on this project and also on backend development, so how can I remove this header using this way and not the basic way ?


Solution

  • so, the solution I found was in loopback documentation - Express settings

    I just add this to my rest config object :

      const config = {
        rest: {
          expressSettings: {
            'x-powered-by': false,
          },
          ...
          ...
        }
       }