Bird
0
0

You want to apply Helmet middleware with custom options to disable the contentSecurityPolicy feature. Which code snippet correctly does this in NestJS?

hard📝 Application Q8 of 15
NestJS - Middleware
You want to apply Helmet middleware with custom options to disable the contentSecurityPolicy feature. Which code snippet correctly does this in NestJS?
Aapp.use(helmet({ contentSecurityPolicy: false }));
Bapp.enableHelmet({ contentSecurityPolicy: false });
Capp.use(helmet.contentSecurityPolicy(false));
Dapp.apply(helmet).with({ contentSecurityPolicy: false });
Step-by-Step Solution
Solution:
  1. Step 1: Recall how to pass options to Helmet

    Helmet accepts an options object when called as a function, e.g., helmet({ contentSecurityPolicy: false }).
  2. Step 2: Check other options for correctness

    There is no app.enableHelmet() method, nor helmet.contentSecurityPolicy() function. app.apply() does not support chaining with with().
  3. Final Answer:

    app.use(helmet({ contentSecurityPolicy: false })); -> Option A
  4. Quick Check:

    Pass options inside helmet() call [OK]
Quick Trick: Pass options as object inside helmet() call [OK]
Common Mistakes:
  • Trying to call non-existent app.enableHelmet()
  • Using helmet.contentSecurityPolicy() incorrectly
  • Misusing app.apply() chaining

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More NestJS Quizzes