helmet


1. CSRF Protection

const helmet = require('helmet');
app.use(helmet.csurf());

2. HTTP Headers Defense

const helmet = require('helmet');
app.use(helmet.contentSecurityPolicy());

3. XSS Filter

const helmet = require('helmet');
app.use(helmet.xssFilter());

4. MIME Sniffing Defense

const helmet = require('helmet');
app.use(helmet.noSniff());

5. HSTS Header

const helmet = require('helmet');
app.use(helmet.hsts({
  maxAge: 1008000000, // 11 years in seconds
}));

6. XSS Protection with Cookies

const helmet = require('helmet');
const { CookieOptions } = require('cookies');
const cookies = new CookieOptions();
app.use(helmet.xssFilter({
  cookies: cookies,
}));

7. Frameguard

8. Don't Sniff Mime Type Header

9. Protect Against Mime Type Sniffing

10. IE NoOpen

11. Hide X-Powered-By Header

12. XSS Cross-Domain Policy

13. Deny Access from Given Patterns

14. Basic CSP with Font and Script Sources

15. CSP with Multiple Sources

16. CSP with Nonce

17. CSP with Hash

18. CSP with Script Enforcement

19. CSP with Mixed Content

20. CSP with Form Action Restriction

21. CSP with Source Map

22. CSP with Dynamic Policy

23. CSP with Custom Report URI

24. CSP with Trusted Types

25. Custom Helmet Middleware