# hzb-midway-cross-domain

> Midway Component for Cross Domain

Latest version **3.8.0** (published 2022-12-08) · MIT license · 0 weekly downloads

## Install

```sh
npm install hzb-midway-cross-domain
pnpm add hzb-midway-cross-domain
yarn add hzb-midway-cross-domain
bun add hzb-midway-cross-domain
```

## Health

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

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 3.8.0 |
| Published | 2022-12-08 |
| First published | 2022-12-08 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Node | >=12 |
| Dependencies | 1 |
| Unpacked size | 27.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Maintainers | wxqcto |

## Links

- npm: https://www.npmjs.com/package/hzb-midway-cross-domain
- npm.io page: https://npm.io/package/hzb-midway-cross-domain

## Dependencies (1)

- [vary](https://npm.io/package/vary.md) ^1.1.2

## Recent versions

- 3.8.0 (latest) — 2022-12-08

## README

## Cross-domain 跨域组件

适用于 `@midwayjs/faas` 、`@midwayjs/web` 、`@midwayjs/koa` 和 `@midwayjs/express` 多种框架的通用跨域组件，支持 `cors` 、`jsonp` 多种模式。

### Usage

1. 安装依赖
```shell
tnpm i @midwayjs/cross-domain --save
```
2. 在 configuration 中引入组件,
```ts
import * as crossDomain from '@midwayjs/cross-domain';
@Configuration({
  imports: [
    // ...other components
    crossDomain
  ],
})
export class AutoConfiguration {}
```



### CORS 配置
```ts
export const cors = {
  allowMethods: string |string[];
  origin: string|Function;
  exposeHeaders: string |string[];
  allowHeaders: string |string[];
  credentials: boolean|Function;
  keepHeadersOnError: boolean;
  maxAge: number;
}
```


### JSONP 配置
```ts
export const jsonp = {
  callback: 'jsonp',
  limit: 512,
}
```

---
_Source: https://npm.io/package/hzb-midway-cross-domain · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
