@onboardbase/nudgeer-safe
TypeScript icon, indicating that this package has built-in type declarations

0.2.1 • Public • Published

Nudgeer Safe

One-click security headers for SSR frameworks

Install the package

npm i @onboardbase/nudgeer-safe
yarn add @onboardbase/nudgeer-safe

NextJS

In NextJS configuration file

/** @type {import('next').NextConfig} */
import NudgeerSafe from '@onboardbase/nudgeer-safe'

const nextConfig = {
  headers: async ()=> {
    return await nudgeerSafe({includeConfig:true,path:"/*"}).next()
  }
  //... rest of config
};

module.exports = nextConfig;

NuxtJS

// https://nuxt.com/docs/api/configuration/nuxt-config
import NudgeerSafe from '@onboardbase/nudgeer-safe'
export default defineNuxtConfig({
  devtools: { enabled: true },
  routeRules:{
    '/**':{
      headers: new NudgeerSafe().nuxt()
    },
  }
})

AstroJS

import { defineConfig } from 'astro/config';
import node from '@astrojs/node'
import tailwind from "@astrojs/tailwind";
import NudgeerSafe from '@onboardbase/nudgeer-safe'

const headers =  new NudgeerSafe().astro()

export default defineConfig({
  output:'server',
  server:{
    headers: headers
  },
  adapter:node({
    mode: 'standalone',
  }),
  integrations: [tailwind()]
});

For more frameworks see docs

Advanced Usage

Create a nudgeer.json in the root directory

{
  "version":"1.0",
  "detatch":true, // default false
  "path":"/:path*",
  "paths":{
    "/:path*":{
      "headers":[
        {
          "key":"content-security-policy",
          "value":"default-src 'self'"
        },
        {
          "key":"referrer-policy",
          "value":"origin"
        },
        {
          "key":"x-content-type-options",
          "value":"nosniff"
        }
      ]
    },
    "/:api*":{
      "headers":[
        {
          "key":"content-security-policy",
          "value":"default-src 'self'"
        },
        {
          "key":"referrer-policy",
          "value":"origin"
        },
        {
          "key":"x-content-type-options",
          "value":"nosniff"
        }
      ]
    }
  }
}

Supported

  • [x] NextJs
  • [x] AstroJs
  • [x] NuxtJs

Package Sidebar

Install

npm i @onboardbase/nudgeer-safe

Homepage

nudgeer.com

Weekly Downloads

6

Version

0.2.1

License

none

Unpacked Size

24 kB

Total Files

39

Last publish

Collaborators

  • akeem_onboardbase
  • mahmoudgalal
  • obbadmin