How to remove response header from restify framwork

220 Views Asked by At

How can I remove a property from the restify response header?

I tried these solutions but working for restify.

    // res.removeHeader("Server"); //Not working
    // res.set("Server", ""); //Adding new header, not updating.
    // res.disable("Server") // Error res.disable is not a function.
  next();
});
1

There are 1 best solutions below

0
Matthias Gwiozda On

The server - header is set by restify itself. You can remove it by setting the server - name to an empty string like this:

const server = restify.createServer({
   name: ''
});

I feel like this should be in the documentation. They are informing about this only indirectly:

options.name String Name of the server. (optional, default "restify")