Skip to content

GlobalPrefixOptions

reference
1 min readUpdated

Kind: Interface

Source: packages/common/interfaces/global-prefix-options.interface.ts

Part of: Common

GlobalPrefixOptions<T> configures routes that should be excluded when applying a global URL prefix. The generic exclude array lets applications provide framework-supported route exclusion definitions, such as path strings or route metadata objects.

Properties

PropertyType
excludeT[]

Diagram

mermaid
graph LR
  A[Application] --> B[Set Global Prefix]
  B --> C[GlobalPrefixOptions<T>]
  C --> D[exclude: T[]]
  D --> E[Routes without global prefix]
  B --> F[All other routes receive prefix]

Usage

ts
import { GlobalPrefixOptions } from '@nestjs/common';

const prefixOptions: GlobalPrefixOptions<string> = {
  exclude: ['health', 'metrics'],
};

app.setGlobalPrefix('api', prefixOptions);

// /api/users
// /api/orders
// /health
// /metrics

AI Coding Instructions

  • Use exclude to list routes that must remain accessible without the configured global prefix.
  • Match the generic type T to the exclusion format accepted by the consuming API, such as string or route exclusion metadata.
  • Keep operational endpoints such as health checks and metrics routes in exclude when external infrastructure expects unprefixed paths.
  • Verify excluded paths against registered controller routes; incorrect path values will not bypass the global prefix.

Used by

2 references from 2 files. Each is a place in this repository where the symbol is actually used — go read one rather than trusting an example.

Imported by (2)

  • ApplicationConfigpackages/core/application-config.ts:13
  • NestApplicationpackages/core/nest-application.ts:54

Was this page helpful?

Download as PDF
GlobalPrefixOptions — NestJS head-to-head