Kind: Interface
Source: packages/common/interfaces/nest-application-options.interface.ts
Part of: Common
NestApplicationOptions configures runtime behavior when creating a Nest application instance. It controls HTTP concerns such as CORS, request body parsing, HTTPS server options, raw body access, and connection shutdown behavior.
Properties
| Property | Type |
|---|---|
cors | `boolean |
bodyParser | boolean |
httpsOptions | HttpsOptions |
rawBody | boolean |
forceCloseConnections | boolean |
Diagram
mermaidgraph LR A[NestFactory.create] --> B[NestApplicationOptions] B --> C[CORS Configuration] B --> D[Body Parser] B --> E[HTTPS Options] B --> F[Raw Body Access] B --> G[Connection Shutdown] C --> H[Nest Application] D --> H E --> H F --> H G --> H
Usage
tsimport { NestFactory } from '@nestjs/core';
import type { NestApplicationOptions } from '@nestjs/common';
import { AppModule } from './app.module';
async function bootstrap() {
const options: NestApplicationOptions = {
cors: {
origin: ['https://example.com'],
credentials: true,
},
bodyParser: true,
rawBody: true,
forceCloseConnections: true,
httpsOptions: {
key: process.env.HTTPS_KEY,
cert: process.env.HTTPS_CERT,
},
};
const app = await NestFactory.create(AppModule, options);
await app.listen(3000);
}
bootstrap();
AI Coding Instructions
- Pass
NestApplicationOptionsas the second argument toNestFactory.create()when configuring an HTTP-based Nest application. - Use
cors: truefor default CORS behavior, or provideCorsOptions/a delegate when origins and credentials require explicit control. - Enable
rawBodyonly when integrations need the unparsed payload, such as webhook signature verification. - Keep
bodyParserenabled unless registering custom parsing middleware or handling request streams manually. - Supply valid Node.js HTTPS server options through
httpsOptions, and considerforceCloseConnectionsfor reliable shutdown in long-lived connection environments.
Used by
6 references from 6 files. Each is a place in this repository where the symbol is actually used — go read one rather than trusting an example.
Imported by (6)
AbstractHttpAdapter—packages/core/adapters/http-adapter.ts:8NestApplication—packages/core/nest-application.ts:54IEntryNestModule—packages/core/nest-factory.ts:39ExpressAdapter—packages/platform-express/adapters/express-adapter.ts:51TestingModule—packages/testing/testing-module.ts:26SocketModule—packages/websockets/socket-module.ts:27
Was this page helpful?