http-cors

2.0.0 • Public • Published

http-cors

Respond correctly to a CORS request

Installation

npm install http-cors

Usage

const http = require('http')
const cors = require('http-cors') // use default options
// const cors = require('http-cors').setup({origin:'example.com'}) // overwrite default options
 
var server = http.createServer(function(request, response) {
  if (cors(request, response)) return // this was an OPTIONS request - no further action needed
 
  // do your things
})
 
server.listen(process.env.PORT || 80)

License

MIT © src.agency

/http-cors/

    Package Sidebar

    Install

    npm i http-cors

    Weekly Downloads

    80

    Version

    2.0.0

    License

    MIT

    Unpacked Size

    4.89 kB

    Total Files

    5

    Last publish

    Collaborators

    • thomas-jensen