
Security News
Deno 2.2 Improves Dependency Management and Expands Node.js Compatibility
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
nitro-helmet
Advanced tools
observerly's Helemt (HTTP security headers) event handler for the Nitro web server
nitro native Helmet-esque security headers.
npm install nitro-helmet
pnpm add nitro-helmet
yarn add nitro-helmet
nitro Helmet is built upon the h3 library. To read more about h3, please consult the h3 repository.
nitro-helmet aims to provide a simple wrapper to define standard security headers for any event handler per nitro event handler, or per route. To use it, simply import the defineHelmetEventHandler
function and wrap your event handler with it as follows:
import { defineHelmetEventHandler } from 'nitro-helmet'
const handler = eventHandler(async event => {
// ...
})
export default defineHelmetEventHandler(handler)
...or...
import { helmetEventHandler } from 'nitro-helmet'
const handler = eventHandler(async event => {
// ...
})
export default helmetEventHandler(handler)
If you would like to override the default options, you can do so as follows:
import { defineHelmetEventHandler } from 'nitro-helmet'
const handler = eventHandler(async event => {
// ...
})
const options: H3HelmetOptions = {}
export default defineHelmetEventHandler(handler, {
crossOriginResourcePolicy: 'same-origin',
crossOriginOpenerPolicy: 'same-origin',
crossOriginEmbedderPolicy: 'require-corp',
contentSecurityPolicy: "default-src 'self';base-uri 'self'",
originAgentCluster: '?1',
referrerPolicy: 'no-referrer',
strictTransportSecurity: 'max-age=15552000; includeSubDomains',
xContentTypeOptions: 'nosniff',
xDNSPrefetchControl: 'off',
xDownloadOptions: 'noopen',
xFrameOptions: 'SAMEORIGIN',
xPermittedCrossDomainPolicies: 'none',
xXSSProtection: '0'
})
The defineHelmetEventHandler
functions take two arguments:
handler
: the event handler to wrap of type EventHandler<T>
, which will ensure typesafety for the event handler return type.options
: the options to pass to the cors handler of type H3HelmetOptions
.FAQs
observerly's Helemt (HTTP security headers) event handler for the Nitro web server
The npm package nitro-helmet receives a total of 3 weekly downloads. As such, nitro-helmet popularity was classified as not popular.
We found that nitro-helmet demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
Security News
React's CRA deprecation announcement sparked community criticism over framework recommendations, leading to quick updates acknowledging build tools like Vite as valid alternatives.
Security News
Ransomware payment rates hit an all-time low in 2024 as law enforcement crackdowns, stronger defenses, and shifting policies make attacks riskier and less profitable.