Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/serviejs/servie-cors
CORS middleware for Servie
https://github.com/serviejs/servie-cors
cors http origin servie xhr
Last synced: about 18 hours ago
JSON representation
CORS middleware for Servie
- Host: GitHub
- URL: https://github.com/serviejs/servie-cors
- Owner: serviejs
- License: other
- Created: 2017-02-04T23:54:56.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2023-12-12T07:22:41.000Z (about 1 year ago)
- Last Synced: 2024-12-10T01:43:57.973Z (19 days ago)
- Topics: cors, http, origin, servie, xhr
- Language: TypeScript
- Size: 627 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Security: SECURITY.md
Awesome Lists containing this project
README
# Servie CORS
[![NPM version](https://img.shields.io/npm/v/servie-cors.svg?style=flat)](https://npmjs.org/package/servie-cors)
[![NPM downloads](https://img.shields.io/npm/dm/servie-cors.svg?style=flat)](https://npmjs.org/package/servie-cors)
[![Build status](https://img.shields.io/travis/serviejs/servie-cors.svg?style=flat)](https://travis-ci.org/serviejs/servie-cors)
[![Test coverage](https://img.shields.io/coveralls/serviejs/servie-cors.svg?style=flat)](https://coveralls.io/r/serviejs/servie-cors?branch=master)> CORS middleware for Servie.
## Installation
```
npm install servie-cors --save
```## Usage
```ts
import { cors } from "servie-cors";
import { compose } from "throwback";
import { get } from "servie-route";const app = compose([cors(), get("/foo", () => new Response(null))]);
```### Options
- `origin?: boolean | string` - Configures the **Access-Control-Allow-Origin** CORS header.
- `expose?: string | string[] | false` - Configures the **Access-Control-Expose-Headers** CORS header.
- `methods?: string | string[] | false` - Configures the **Access-Control-Allow-Methods** CORS header.
- `headers?: string | string[] | false` - Configures the **Access-Control-Allow-Headers** CORS header.
- `maxAge?: number` - Configures the **Access-Control-Max-Age** CORS header.
- `credentials?: boolean` - Configures the **Access-Control-Allow-Credentials** CORS header.
- `optionsContinue?: boolean` - Pass the CORS preflight **OPTIONS** request to the `next()` handler.
- `optionsStatus?: number` - Provides a status code to use for successful OPTIONS requests.## TypeScript
This project is written using [TypeScript](https://github.com/Microsoft/TypeScript) and publishes the definitions directly to NPM.
## License
Apache 2.0