Security Headers
How to do that?
Well,
- Use
X-Content-Type-Optionsto preventMIMEtype sniffing. - Implement
X-Frame-Optionsto avoidclickjackingattacks. - Set
X-XSS-Protectionto active the browser’sXSSfilter.
Example:
app.use((req, res, next) => {
res.setHeader('X-Content-Type-Options', 'nosniff');
res.setHeader('X-Frame-Options', 'DENY');
res.setHeader('X-XSS-Protection', '1; mode=block');
next();
});
Want to learn more? Check out the OWASP Secure Headers Project