Skip to content

srcagency/http-cors

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

Respond correctly to a CORS request

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published