Skip to content

Latest commit

 

History

History
29 lines (20 loc) · 529 Bytes

README.md

File metadata and controls

29 lines (20 loc) · 529 Bytes

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

http
  .createServer((req, res) => {
    if (cors(req, res)) return // this was an OPTIONS request - no further action needed

    // do your things
  })
  .listen(80)

License

MIT