Helmet

使用各种HTTP标头帮助保护Express应用程序。(Help secure Express apps with various HTTP headers.)

Github星跟蹤圖

Helmet

npm version
npm dependency status
Build Status
FOSSA Status

Helmet helps you secure your Express apps by setting various HTTP headers. It's not a silver bullet, but it can help!

Looking for a version of Helmet that supports the Koa framework?

Quick start

First, run npm install helmet --save for your app. Then, in an Express (or Connect) app:

const express = require('express')
const helmet = require('helmet')

const app = express()

app.use(helmet())

// ...

It's best to use Helmet early in your middleware stack so that its headers are sure to be set.

You can also use its pieces individually:

app.use(helmet.xssFilter())
app.use(helmet.frameguard())

You can disable a middleware that's normally enabled by default. This will disable frameguard but include the other defaults.

app.use(helmet({
  frameguard: false
}))

You can also set options for a middleware. Setting options like this will always include the middleware, whether or not it's a default.

app.use(helmet({
  frameguard: {
    action: 'deny'
  }
}))

If you're using Express 3, make sure these middlewares are listed before app.router.

How it works

Helmet is a collection of 14 smaller middleware functions that set HTTP response headers. Running app.use(helmet()) will not include all of these middleware functions by default., Module, Default?, ---, ---, contentSecurityPolicy for setting Content Security Policy, crossdomain for handling Adobe products' crossdomain requests, dnsPrefetchControl controls browser DNS prefetching, ✓, expectCt for handling Certificate Transparency, featurePolicy to limit your site's features, frameguard to prevent clickjacking, ✓, hidePoweredBy to remove the X-Powered-By header, ✓, hpkp for HTTP Public Key Pinning, hsts for HTTP Strict Transport Security, ✓, ieNoOpen sets X-Download-Options for IE8+, ✓, noCache to disable client-side caching, noSniff to keep clients from sniffing the MIME type, ✓, referrerPolicy to hide the Referer header, xssFilter adds some small XSS protections, ✓, You can see more in the documentation.

主要指標

概覽
名稱與所有者helmetjs/helmet
主編程語言TypeScript
編程語言JavaScript (語言數: 2)
平台Linux, Mac, Windows
許可證MIT License
所有者活动
創建於2012-02-01 22:54:45
推送於2025-07-09 21:06:56
最后一次提交
發布數105
最新版本名稱v8.1.0 (發布於 2025-03-17 18:55:13)
第一版名稱v0.4.2 (發布於 2014-10-16 16:35:20)
用户参与
星數10.5k
關注者數100
派生數382
提交數1k
已啟用問題?
問題數342
打開的問題數2
拉請求數95
打開的拉請求數0
關閉的拉請求數52
项目设置
已啟用Wiki?
已存檔?
是復刻?
已鎖定?
是鏡像?
是私有?