securityHeadersMiddleware.js 853 B

1234567891011121314151617181920212223242526
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. exports.default = securityHeadersMiddleware;
  6. /**
  7. * Copyright (c) Facebook, Inc. and its affiliates.
  8. *
  9. * This source code is licensed under the MIT license found in the
  10. * LICENSE file in the root directory of this source tree.
  11. */
  12. function securityHeadersMiddleware(req, res, next) {
  13. // Block any cross origin request.
  14. if (typeof req.headers.origin === 'string' && !req.headers.origin.match(/^https?:\/\/localhost:/)) {
  15. next(new Error('Unauthorized request from ' + req.headers.origin + '. This may happen because of a conflicting browser extension. Please try to disable it and try again.'));
  16. return;
  17. } // Block MIME-type sniffing.
  18. res.setHeader('X-Content-Type-Options', 'nosniff');
  19. next();
  20. }
  21. //# sourceMappingURL=securityHeadersMiddleware.js.map