https://github.com/trekjs/cors
Cross Origin Resource Sharing (CORS) middleware
https://github.com/trekjs/cors
Last synced: about 1 month ago
JSON representation
Cross Origin Resource Sharing (CORS) middleware
- Host: GitHub
- URL: https://github.com/trekjs/cors
- Owner: trekjs
- License: mit
- Created: 2016-11-05T06:47:26.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2017-04-13T10:53:22.000Z (about 8 years ago)
- Last Synced: 2025-04-19T17:26:06.484Z (2 months ago)
- Language: JavaScript
- Size: 73.2 KB
- Stars: 1
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# cors
Cross-Origin Resource Sharing(CORS) middleware
## Installation
```
$ npm install trek-cors --save
```## Examples
```js
'use strict'const Engine = require('trek-engine')
const sessions = require('trek-sessions')
const bodyParser = require('trek-body-parser')
const cors = require('trek-cors')async function start () {
const app = new Engine()app.use(sessions())
app.use(bodyParser())
app.use(cors())
app.use(ctx => {
ctx.res.body = 'Hello CORS'
})app.on('error', (err, ctx) => {
console.log(err)
})app.run(3000)
}start().catch(console.log)
```## API
```js
csrf({
credentials: false,
origins: '*',
methods: 'GET,HEAD,PUT,POST,DELETE,PATCH',
maxAge: 0
})
```## Badges
[](https://travis-ci.org/trekjs/cors)
[](https://codecov.io/gh/trekjs/cors)
---
> [fundon.me](https://fundon.me) ·
> GitHub [@fundon](https://github.com/fundon) ·
> Twitter [@_fundon](https://twitter.com/_fundon)