freeCodeCamp/curriculum/challenges/chinese-traditional/09-information-security/information-security-with-h.../install-and-require-helmet.md

1.8 KiB
Raw Blame History

id title challengeType forumTopicId dashedName
587d8247367417b2b2512c36 安裝和引入 Helmet 2 301581 install-and-require-helmet

--description--

你可以採用下面的任意一種編寫代碼的方式來完成這些挑戰:

完成本項目後,請將一個正常運行的 demo項目演示託管在可以公開訪問的平臺。 然後在 Solution Link 字段中提交它的 URL。

Helmet 通過設置各種 HTTP 頭來保護你的 Express 應用程序。

--instructions--

你在這些課程中寫的所有代碼都在 myApp.js 文件中,在初始代碼之間。 不要改變或刪除我們爲你添加的代碼。

安裝 Helmet 的 3.21.3 版本,然後引入它。 你可以用 npm install --save-exact package@version 來安裝一個特定版本的軟件包,或者直接將其添加到你的 package.json 中。

--hints--

helmet 版本 3.21.3 應該在 package.json 中。

(getUserInput) =>
  $.get(getUserInput('url') + '/_api/package.json').then(
    (data) => {
      const packJson = JSON.parse(data);
      const helmet = packJson.dependencies.helmet;
      assert(helmet === '3.21.3' || helmet === '^3.21.3');
    },
    (xhr) => {
      throw new Error(xhr.responseText);
    }
  );

--solutions--

/**
  Backend challenges don't need solutions, 
  because they would need to be tested against a full working project. 
  Please check our contributing guidelines to learn more.
*/