trekjs / cors

Cross Origin Resource Sharing (CORS) middleware

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

License:MIT License


Languages

Language:JavaScript 100.0%