xss-shield
v1.0.1
Published
A powerful middleware for securing your express.js applications against cross-site scripting (XSS) attacks
Downloads
509
Maintainers
Readme
Installation
To use this middleware, first install it using npm or yarn:
npm install xss-shield
or
yarn add xss-shield
Usage
To use this middleware in your Express.js application, simply require or import it and add it to your middleware stack:
const express = require('express');
const xssShield = require('xss-shield');
const app = express();
// Add the middleware to the middleware stack
app.use(xssShield());
You can also pass options to the middleware to customize its behavior. See the xss documentation for available options.
const express = require('express');
const xssShield = require('xss-shield');
const app = express();
// Add the middleware to the middleware stack with options
app.use(xssShield({
whiteList: {
a: ['href', 'title', 'target'],
img: ['src', 'alt'],
}
}));
License
xss-shield is licensed under the MIT License. See LICENSE for more information.