Skip to content

Baroshem/nuxt-security

main
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
November 27, 2023 21:55
December 5, 2023 10:44
November 27, 2023 15:26
November 27, 2023 15:26
November 27, 2023 20:23
October 6, 2022 21:35
October 6, 2022 21:35
October 19, 2023 10:03
October 26, 2023 12:29
February 28, 2023 13:39
October 18, 2023 16:55
October 26, 2023 02:53
December 5, 2023 10:44
December 4, 2023 14:52

nuxt-security

npm version npm downloads Github Actions CI License Nuxt

Nuxt Security

Automatically configure your app to follow OWASP security patterns and principles by using HTTP Headers and Middleware.

This module works with Nuxt 3 only

Features

  • Security response headers (including CSP for SSG apps)
  • Request Size & Rate Limiters
  • Cross Site Scripting (XSS) Validation
  • Cross-Origin Resource Sharing (CORS) support
  • Hide X-Powered-By header and remove console loggers utils
  • [Optional] Allowed HTTP Methods, Basic Auth, CSRF

Usage

Install the module:

npm i -D nuxt-security@rc
yarn add -D nuxt-security@rc
pnpm add -D nuxt-security@rc

Add the module in the modules array in nuxt.config.ts:

export default defineNuxtConfig({
  modules: ["nuxt-security"],
})

And that's it! The module will now register route rules and server middlewares globally so that your application will be more secured.

Configuration

You can pass configuration to the module in the nuxt.config.ts like following:

export default defineNuxtConfig({
  modules: ["nuxt-security"],
  security: {
    // options
  }
})

For all available configuration options check out the docs.

Development

  • Run yarn dev:prepare to generate type stubs.
  • Use yarn dev to start playground in development mode.

License

MIT License