JSPM

@nestjs-kitchen/headers

1.0.1
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 114
  • Score
    100M100P100Q63136F
  • License MIT

An convenient way to add custom HTTP headers.

Package Exports

  • @nestjs-kitchen/headers

Readme

@nestjs-kitchen/headers

NPM Version NPM License codecov

An convenient way to add custom HTTP headers.


Install

$ npm install --save @nestjs-kitchen/headers

Usage

Example

Register module:

// in app.module.ts
@Module({
  imports: [
    // ...
    HeadersModule.register({
      headers: {
        'X-Custom-Header': 'custom-value'
      }
    }),
    // ...
  ],
})
export class AppModule {}

Options

Option Type Default Description
headers Headers | ((req: any) => Headers | Promise<Headers>) required HTTP headers to set. Can be a static object or a function that dynamically computes headers based on the request.
include (string | RegExp)[] Optional path inclusion filter. Headers will only be applied to matching requests.
exclude (string | RegExp)[] Path exclusion filter. Has higher priority than include. Requests matching any exclude pattern will skip setting headers.
overwrite boolean false Whether to overwrite existing headers. If false, headers will only be set if they do not already exist.
debug boolean false Enable debug logging. When true, debug information will be logged to the configured logger.

License

MIT License