Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

106
Views
helmet.js custom options for one middleware while enabling others

I want to set some custom options for one of the helmet.js middlewares but I don't understand if by doing so the other middlewares are enabled or I have to enable them explicitly ?

From helmet.js docs:

// Sets all of the defaults, but overrides `script-src` and disables the default `style-src`
app.use(
  helmet.contentSecurityPolicy({
    useDefaults: true,
    directives: {
      "script-src": ["'self'", "example.com"],
      "style-src": null,
    },
  })
);

Should I add app.use(helmet()) before the above code ?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

app.use(helmet()) includes all of Helmet's default middlewares with their default options.

app.use(helmet.contentSecurityPolicy()) only includes the Content Security Policy middleware. In other words, you won't get the rest of Helmet's middlewares.

To include all of Helmet's defaults and customize the CSP middleware, specify it under the top-level helmet():

app.use(
  helmet({
    contentSecurityPolicy: {
      // ...
    },
  })
);
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!