import type { RequestHandler } from '@sveltejs/kit'; import { type AllowedOrigin } from './origins.js'; export interface CorsOptions { /** * If `true`, reflects request origin in `Access-Control-Allow-Origin`. If set to `*` or a * specific origin, sets `Access-Control-Allow-Origin` to that value. If a RegExp or an array of * strings/RegExps, reflects the request origin in `Access-Control-Allow-Origin` if it matches any * of the strings / RegExps provided. If explicitly set to `false` or `undefined`, does not set * the `Access-Control-Allow-Origin` header. * @default '*' */ origin?: AllowedOrigin | undefined; /** * Sets `Access-Control-Allow-Methods` to the given string or array of strings (joined with `,`). * If explicitly set to `undefined`, does not set the `Access-Control-Allow-Methods` header. * @default 'GET,HEAD,PUT,PATCH,POST,DELETE' */ methods?: string | string[] | undefined; /** * Sets `Access-Control-Allow-Headers` to the given string or array of strings (joined with `,`). * If set to `true`, reflects the `Access-Control-Request-Headers` header. If explicitly set to * `false`, or `undefined`, does not set the `Access-Control-Allow-Headers` header. * @default true */ allowedHeaders?: string | string[] | boolean | undefined; /** * Sets `Access-Control-Expose-Headers` to the given string or array of strings (joined with `,`). * If not specified, does not set `Access-Control-Expose-Headers`. */ exposedHeaders?: string | string[] | undefined; /** * Sets `Access-Control-Allow-Credentials` to `true` if `true`, or unset if `false`. * @default false */ credentials?: boolean | undefined; /** * Sets `Access-Control-Max-Age` to the given number. If unset, does not set * `Access-Control-Max-Age`. */ maxAge?: number | undefined; /** * If set, returns the given status code for preflight requests. If unset, returns 204. Useful for * clients that fail if an OPTIONS request returns 204 (mostly legacy browsers). * @default 204 */ optionsStatusSuccess?: number | undefined; } export declare function cors(inputOptions: CorsOptions | undefined, request: Request, response: Response): Response; /** * A function that wraps a request handler to add CORS headers to the response. Provides an * `OPTIONS` member which returns a default response, with CORS headers, for an OPTIONS request. */ export interface CorsWrapper { (handler: RequestHandler): RequestHandler; OPTIONS: RequestHandler; } /** * Creates a {@link CorsWrapper} function that wraps a `RequestHandler` function and applies CORS * headers to the response. Also provides an `OPTIONS` member that returns a default response for * OPTIONS requests. */ export declare function createCorsWrapper(options?: CorsOptions): CorsWrapper;