xssProtection.js 327 B

1234567891011121314
  1. 'use strict';
  2. const utils = require('../utils');
  3. module.exports = options => {
  4. return async function xssProtection(ctx, next) {
  5. await next();
  6. const opts = utils.merge(options, ctx.securityOptions.xssProtection);
  7. if (utils.checkIfIgnore(opts, ctx)) return;
  8. ctx.set('x-xss-protection', opts.value);
  9. };
  10. };