import { App } from '../app'; import { Method, MiddlewareContext } from '../types'; type OriginFn = (ctx: MiddlewareContext) => string; type Origin = string | string[] | OriginFn; /** * Cross-Origin Resource Sharing (CORS) configuration object. * * This type allows flexible control over allowed origins, headers, and methods. * * Defaults (if a field is omitted): * - `methods`: `['DELETE', 'GET', 'HEAD', 'OPTIONS', 'PATCH', 'POST', 'PUT']` * - `allowedHeaders`: `['Content-Type', 'Authorization']` * - `credentials`: not sent unless explicitly set to `true` * - `exposedHeaders`: not set unless provided * - `maxAge`: not set unless provided */ export type Cors = { /** * Allowed origin(s). Can be: * - a string (exact match) * - an string array (any item exact match) * - a function that receives the request context and returns a valid origin */ origin: Origin; /** * Allowed HTTP methods for CORS requests. * @default * [`DELETE`, `GET`, `HEAD`, `OPTIONS`, `PATCH`, `POST`, `PUT`] */ methods?: Method[]; /** * Allowed headers for incoming requests. * @default * ['Content-Type', 'Authorization'] */ allowedHeaders?: string[]; /** * Headers that can be exposed to the browser. * Default: none * @default undefined */ exposedHeaders?: string[]; /** * How long the results of a preflight request can be cached (in seconds). * Default: not set * @default undefined */ maxAge?: number; /** * Whether to include `Access-Control-Allow-Credentials: true`. * Default: not set (credentials will not be sent) */ credentials?: boolean; }; export declare const cors: (opts: Cors | string | ((ctx: MiddlewareContext) => string)) => App; export {};