Skip to content
/ cors Public

Cross Origin Resource Sharing (CORS) middleware

License

Notifications You must be signed in to change notification settings

trekjs/cors

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

cors

Cross-Origin Resource Sharing(CORS) middleware

Installation

$ npm install trek-cors --save

Examples

'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

csrf({
  credentials: false,
  origins: '*',
  methods: 'GET,HEAD,PUT,POST,DELETE,PATCH',
  maxAge: 0
})

Badges

Build Status codecov


fundon.me  ·  GitHub @fundon  ·  Twitter @_fundon

About

Cross Origin Resource Sharing (CORS) middleware

Resources

License

Stars

Watchers

Forks

Packages

No packages published