<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: sampod76</title>
    <description>The latest articles on Forem by sampod76 (@sampodnath).</description>
    <link>https://forem.com/sampodnath</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1995768%2F71680dd6-1eb6-44bf-b77f-402e62635543.jpeg</url>
      <title>Forem: sampod76</title>
      <link>https://forem.com/sampodnath</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/sampodnath"/>
    <language>en</language>
    <item>
      <title>🚀 Boost Your Node.js Security with Helmet.js! 🛡️</title>
      <dc:creator>sampod76</dc:creator>
      <pubDate>Tue, 10 Sep 2024 10:44:38 +0000</pubDate>
      <link>https://forem.com/sampodnath/boost-your-nodejs-security-with-helmetjs-27gn</link>
      <guid>https://forem.com/sampodnath/boost-your-nodejs-security-with-helmetjs-27gn</guid>
      <description>&lt;p&gt;Building secure web applications is more important than ever. If you're using Node.js and Express, Helmet.js is your go-to middleware to add an extra layer of security by configuring various HTTP headers.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Content Security Policy (CSP): Fine-tune your scriptSrc and styleSrc to limit what external resources can be loaded, reducing XSS attacks.&lt;/li&gt;
&lt;li&gt;Cross-Origin Policies: Secure cross-origin resource and embedder policies to prevent unauthorized resource sharing.&lt;/li&gt;
&lt;li&gt;HSTS Preloading: Enforce HTTPS to all visitors by preloading HTTP Strict Transport Security.&lt;/li&gt;
&lt;li&gt;Frameguard: Prevent clickjacking attacks by controlling who can embed your site in iframes.&lt;/li&gt;
&lt;li&gt;XSS and MIME Protection: Add X-XSS-Protection and X-Content-Type-Options headers to guard against XSS attacks and MIME sniffing.
💡 Pro Tip: Always audit your security headers regularly and stay up-to-date with emerging threats to ensure comprehensive protection.
`import helmet from 'helmet';&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;const app: Application = express();&lt;/p&gt;

&lt;p&gt;app.use(&lt;br&gt;
  helmet({&lt;br&gt;
    contentSecurityPolicy: {&lt;br&gt;
      directives: {&lt;br&gt;
        defaultSrc: ["'self'"],&lt;br&gt;
        scriptSrc: ["'self'", "'unsafe-inline'"],&lt;br&gt;
        //   scriptSrc: ["'self'", "'unsafe-inline'", "example.com"],&lt;br&gt;
        styleSrc: ["'self'", "'unsafe-inline'"],&lt;br&gt;
        imgSrc: ["'self'", 'data:'],&lt;br&gt;
        connectSrc: ["'self'"],&lt;br&gt;
        fontSrc: ["'self'"],&lt;br&gt;
        objectSrc: ["'none'"],&lt;br&gt;
        mediaSrc: ["'self'"],&lt;br&gt;
        frameSrc: ["'self'"],&lt;br&gt;
        upgradeInsecureRequests: [],&lt;br&gt;
      },&lt;br&gt;
    },&lt;br&gt;
    crossOriginEmbedderPolicy: true,&lt;br&gt;
    crossOriginOpenerPolicy: { policy: 'same-origin' },&lt;br&gt;
    crossOriginResourcePolicy: { policy: 'same-origin' },&lt;br&gt;
    dnsPrefetchControl: { allow: false },&lt;br&gt;
    //   expectCt: {&lt;br&gt;
    //     enforce: true,&lt;br&gt;
    //     maxAge: 86400, // 1 day in seconds&lt;br&gt;
    //   },&lt;br&gt;
    frameguard: { action: 'deny' },&lt;br&gt;
    hsts: {&lt;br&gt;
      maxAge: 63072000, // 2 years in seconds&lt;br&gt;
      includeSubDomains: true,&lt;br&gt;
      preload: true,&lt;br&gt;
    },&lt;br&gt;
    hidePoweredBy: true,&lt;br&gt;
    ieNoOpen: true,&lt;br&gt;
    noSniff: true,&lt;br&gt;
    permittedCrossDomainPolicies: { permittedPolicies: 'none' },&lt;br&gt;
    referrerPolicy: { policy: 'strict-origin-when-cross-origin' },&lt;br&gt;
    xssFilter: true,&lt;br&gt;
  }),&lt;br&gt;
);&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fkl9u09kvkqnrf4jnl8cr.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fkl9u09kvkqnrf4jnl8cr.png" alt="Image description" width="" height=""&gt;&lt;/a&gt;`&lt;/p&gt;

</description>
      <category>node</category>
      <category>security</category>
      <category>express</category>
    </item>
  </channel>
</rss>
