Skip to content

Commit

Permalink
docs: use allowlist in readme
Browse files Browse the repository at this point in the history
closes #199
closes #200
  • Loading branch information
jkasun authored and dougwilson committed Jun 29, 2020
1 parent d7ef6c4 commit 8866c3b
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions README.md
Expand Up @@ -120,7 +120,7 @@ var corsOptions = {
}

app.get('/products/:id', cors(corsOptions), function (req, res, next) {
res.json({msg: 'This is CORS-enabled for a whitelisted domain.'})
res.json({msg: 'This is CORS-enabled for an allowed domain.'})
})

app.listen(80, function () {
Expand Down Expand Up @@ -169,10 +169,10 @@ var express = require('express')
var cors = require('cors')
var app = express()

var whitelist = ['http://example1.com', 'http://example2.com']
var allowlist = ['http://example1.com', 'http://example2.com']
var corsOptionsDelegate = function (req, callback) {
var corsOptions;
if (whitelist.indexOf(req.header('Origin')) !== -1) {
if (allowlist.indexOf(req.header('Origin')) !== -1) {
corsOptions = { origin: true } // reflect (enable) the requested origin in the CORS response
} else {
corsOptions = { origin: false } // disable CORS for this request
Expand All @@ -181,7 +181,7 @@ var corsOptionsDelegate = function (req, callback) {
}

app.get('/products/:id', cors(corsOptionsDelegate), function (req, res, next) {
res.json({msg: 'This is CORS-enabled for a whitelisted domain.'})
res.json({msg: 'This is CORS-enabled for an allowed domain.'})
})

app.listen(80, function () {
Expand Down

0 comments on commit 8866c3b

Please sign in to comment.