# @tinyhttp/cors [![npm][npm-img]][npm-url] [![GitHub Workflow Status][gh-actions-img]][github-actions] [![Coverage][cov-img]][cov-url]

A rewrite of expressjs/cors module.

HTTP cors header middleware.

Install

sh pnpm i @tinyhttp/cors

API

ts import { cors } from '@tinyhttp/cors'

cors(options)

Returns the CORS middleware with the settings specified in the parameters

Options

The default configuration is:

json { "origin": "*", "methods": ["GET", "HEAD", "PUT", "PATCH", "POST", "DELETE"], "optionsSuccessStatus": 204, "preflightContinue": false }

Example

```ts import { App } from '@tinyhttp/app' import { cors } from '@tinyhttp/cors'

const app = new App()

app .use(cors({ origin: 'https://myfantastic.site/' })) .options('*', cors()) .get('/', (req, res) => { res.send('The headers contained in my response are defined in the cors middleware') }) .listen(3000) ```