Nuxt 安全
透過使用 HTTP 頭和中介軟體,自動配置您的應用程式以遵循 OWASP 安全模式和原則。
此模組僅適用於 Nuxt 3
功能
- 安全響應頭(包括 SSG 應用程式的 CSP)
- 請求大小和速率限制器
- 跨站指令碼 (XSS) 驗證
- 跨域資源共享 (CORS) 支援
- 隱藏
X-Powered-By
頭並刪除控制檯日誌實用程式 [可選]
允許的 HTTP 方法、基本身份驗證、CSRF
使用
安裝模組
npx nuxi@latest module add security
就是這樣!該模組現在將全域性註冊路由規則和伺服器中介軟體,以便您的應用程式更加安全。
配置
您可以在 nuxt.config.ts
中傳遞配置到模組,如下所示
export default defineNuxtConfig({
modules: ["nuxt-security"],
security: {
// options
}
})
有關所有可用配置選項,請檢視文件。
開發
- 執行
yarn dev:prepare
以生成型別存根。 - 使用
yarn dev
以開發模式啟動 playground。