freeCodeCamp/curriculum/challenges/chinese/06-information-security-and.../information-security-with-h.../configure-helmet-using-the-...

1.6 KiB
Raw Blame History

id title challengeType videoUrl localeTitle
587d8249367417b2b2512c40 Configure Helmet Using the parent helmet() Middleware 2 配置头盔使用“父”头盔()中间件

Description

提醒一下,这个项目是基于Glitch的以下入门项目构建的,或者是从GitHub克隆的。 app.usehelmet将自动包含上面介绍的所有中间件noCache和contentSecurityPolicy除外但如果需要可以启用这些中间件。您还可以使用配置对象单独禁用或配置任何其他中间件。 //示例app.use(helmet({ frameguard: { // configure action: 'deny' }, contentSecurityPolicy: { // enable and configure directives: { defaultSrc: ["self"], styleSrc: ['style.com'], } }, dnsPrefetchControl: false // disable }))我们分别为教学目的引入了每个中间件,并且易于测试。使用“父”头盔()中间件对于真实项目来说是最简单,更清洁的。

Instructions

Tests

tests:
  - text: 没有测试 - 这是一个描述性的挑战
    testString: assert(true)

Challenge Seed

Solution

// solution required