Variable corsOptionsConst
corsOptions: {
origin: (
origin: undefined | string,
callback: (err: null | Error, allow?: boolean) => void,
) => void;
credentials: boolean;
optionsSuccessStatus: number;
methods: string[];
allowedHeaders: string[];
exposedHeaders: string[];
} = ...
Type declaration
origin: (
origin: undefined | string,
callback: (err: null | Error, allow?: boolean) => void,
) => void
credentials: boolean
optionsSuccessStatus: number
methods: string[]
CORS (Cross-Origin Resource Sharing) Configuration
Configures cross-origin request policies for the Express application. This configuration controls which domains can access the API, what HTTP methods are allowed, and which headers can be sent in cross-origin requests. The origin validation function checks incoming requests against a whitelist of allowed domains from environment variables.
The configuration supports both development and production environments by allowing requests with no origin (mobile apps, Postman) and dynamically validating origins against the CORS_ORIGIN environment variable. Failed CORS validations are logged for security monitoring purposes.
CORS configuration object for Express cors middleware