MCPcopy Index your code
hub / github.com/Baroshem/nuxt-security

github.com/Baroshem/nuxt-security @v2.6.0

Chat with this repo
repository ↗ · DeepWiki ↗ · release v2.6.0 ↗ · + Follow
37 symbols 202 edges 90 files 3 documented · 8% updated 8d agov2.6.0 · 2026-05-12★ 97532 open issues
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

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.X and newer (4.X)

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:

npx nuxi@latest module add 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

Extension points exported contracts — how you extend this code

SecurityHeaders (Interface)
(no doc)
src/types/headers.ts
ModuleOptions (Interface)
(no doc)
src/types/module.ts
NuxtOptions (Interface)
(no doc)
src/types/module.ts
RuntimeConfig (Interface)
(no doc)
src/types/module.ts
NuxtHooks (Interface)
(no doc)
src/types/module.ts

Core symbols most depended-on inside this repo

setup
called by 17
src/module.ts
resolveSecurityRules
called by 15
src/runtime/nitro/context/index.ts
defaultSecurityConfig
called by 3
src/defaultConfig.ts
generateHash
called by 3
src/utils/crypto.ts
headerStringFromObject
called by 3
src/utils/headers.ts
collapseWhitespace
called by 2
test/fixtures/ssgHashes/server/plugins/transform-inline.ts
getNameFromKey
called by 2
src/utils/headers.ts
headerObjectFromString
called by 2
src/utils/headers.ts

Shape

Function 29
Interface 8

Languages

TypeScript100%

Modules by API surface

src/utils/headers.ts8 symbols
src/types/module.ts7 symbols
src/module.ts4 symbols
test/ssgHashes.test.ts3 symbols
src/runtime/nitro/context/index.ts3 symbols
src/utils/crypto.ts2 symbols
src/runtime/server/middleware/rateLimiter.ts2 symbols
test/fixtures/ssrNonce/public/loader.js1 symbols
test/fixtures/ssgHashes/server/plugins/transform-inline.ts1 symbols
src/types/headers.ts1 symbols
src/runtime/server/middleware/basicAuth.ts1 symbols
src/runtime/nitro/plugins/50-updateCsp.ts1 symbols

For agents

$ claude mcp add nuxt-security \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact

Ask about this repo answers extend the page