@davaux/cors
v0.9.0
Published
CORS middleware for Davaux
Readme
@davaux/cors
CORS middleware for Davaux.
Installation
npm install @davaux/corsSetup
// davaux.config.ts
import { defineConfig } from 'davaux/config'
import { cors } from '@davaux/cors'
export default defineConfig({
middleware: [
cors({ origin: 'https://app.example.com', credentials: true }),
],
})Options
| Option | Type | Default | Description |
|---|---|---|---|
| origin | string \| string[] \| (origin) => boolean | — | Allowed origin(s). '*' for any, exact string, whitelist array, or custom function (required) |
| methods | string[] | ['GET','HEAD','PUT','PATCH','POST','DELETE'] | Allowed HTTP methods |
| allowedHeaders | string[] | Reflects preflight | Allowed request headers |
| exposedHeaders | string[] | — | Headers the browser may read from the response |
| credentials | boolean | false | Set Access-Control-Allow-Credentials: true |
| maxAge | number | — | Preflight cache duration in seconds |
credentials: truerequires a specificorigin— browsers reject credentialed responses with a wildcard origin.
