This package provides an Express middleware specifically designed to disable the `X-XSS-Protection` HTTP header by setting its value to `0`. This header, once intended to mitigate cross-site scripting (XSS) attacks, has been largely deprecated by browser vendors due to its propensity to introduce new security vulnerabilities rather than solve them. It is part of the Helmet.js project, a collection of middlewares for securing Express apps. The current stable version is 2.0.0. The package maintains a low release cadence, primarily updating for Node.js compatibility or critical bug fixes, as its core functionality (disabling a header) is stable and intentionally minimal. Its key differentiator is its explicit recommendation and implementation for removing a problematic legacy security feature, contrasting with older practices that advocated its use. This library is a targeted solution for modern web security practices, where XSS mitigation is handled by Content Security Policy (CSP) and robust input sanitization instead of this unreliable header.
npm install x-xss-protectionVerified import paths — ran on the pinned version, not inferred.
Demonstrates how to integrate the middleware into an Express application to disable the X-XSS-Protection header.
Always disable the header using this middleware (`xXssProtection()`), or implement a robust Content Security Policy (CSP) and proper input sanitization instead.
If legacy `X-XSS-Protection` behavior is absolutely required (which is generally not recommended due to severe security risks), implement custom middleware to set the header manually.
Review your Helmet.js configuration. If using Helmet v6+, this package is likely unnecessary. For older Helmet versions or standalone use, continue using this middleware as intended.
Use `import xXssProtection from 'x-xss-protection'` for ESM or `const xXssProtection = require('x-xss-protection')` for CommonJS.Add `const xXssProtection = require('x-xss-protection')` or `import xXssProtection from 'x-xss-protection'` at the top of your file.No dependency data recorded yet.