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
| Property | Type |
|---|---|
exclude | T[] |
Diagram
mermaidgraph 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
tsimport { 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
excludeto list routes that must remain accessible without the configured global prefix. - Match the generic type
Tto the exclusion format accepted by the consuming API, such asstringor route exclusion metadata. - Keep operational endpoints such as health checks and metrics routes in
excludewhen 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)
ApplicationConfig—packages/core/application-config.ts:13NestApplication—packages/core/nest-application.ts:54
Was this page helpful?