fastify-helmet
Important security headers for Fastify. It is a port from express of
helmet
Install
npm i fastify-helmet --save
Usage
Simply require this plugin, and the basic security headers will be set.
const fastify = require('fastify')()
const helmet = require('fastify-helmet')
fastify.register(
helmet,
{ hidePoweredBy: { setTo: 'PHP 4.2.0' } }
)
fastify.listen(3000, err => {
if (err) throw err
console.log('Server listenting on localhost:', fastify.server.address().port)
})
How it works
fastify-helmet
is a collection of 12 smaller middleware functions that set HTTP headers. Running fastify.register(helmet)
will not include all of these middleware functions by default.
fastify-helmet
accept the same options of Helmet, and you can see more in the helmet documentation.
License
MIT