# @umajs/plugin-cors

> 跨域配置插件

Latest version **0.0.1** (published 2021-10-18) · ISC license · 0 weekly downloads

## Install

```sh
npm install @umajs/plugin-cors
pnpm add @umajs/plugin-cors
yarn add @umajs/plugin-cors
bun add @umajs/plugin-cors
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.1 |
| Published | 2021-10-18 |
| First published | 2021-10-18 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 2.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 2 |
| Author | BubbleM |
| Maintainers | edwwardzzz, dazjean, bubblelm, cocoboom, liushaohua, wangliang826 |

## Links

- npm: https://www.npmjs.com/package/@umajs/plugin-cors
- Repository: https://github.com/Umajs/plugin-cors
- Homepage: https://github.com/Umajs/plugin-cors#readme
- Issues: https://github.com/Umajs/plugin-cors/issues
- npm.io page: https://npm.io/package/@umajs/plugin-cors

## Recent versions

- 0.0.1 (latest) — 2021-10-18

## README

# @umajs/plugin-cors

## Install
```
npm i @umajs/plugin-cors
```

## Usage
```js
// config/plugin.config.ts
export default {
    'cors': true
};
```

`options`均为可选项
- origin: ctx.request.headers.origin || '*', // 指定了该响应的资源是否被允许与给定的origin共享
- method: 'OPTIONS, GET, PUT, POST, DELETE', // 客户端所要访问的资源允许使用的方法或方法列表
- maxAge: 300, // 预检请求的返回结果可以被缓存多久
- headers: ['x-requested-with', 'accept', 'origin', 'content-type'], // 列出了将会在正式请求的 Access-Control-Request-Headers 字段中出现的首部信息
- expose: ['X-My-Custom-Header', 'X-Another-Custom-Header'], // 哪些首部可以作为响应的一部分暴露给外部
- Credentials: true, // 是否可以将对请求的响应暴露给页面
```

---
_Source: https://npm.io/package/@umajs/plugin-cors · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
