Created
April 16, 2015 15:21
-
-
Save agreen757/0fb00deb4b379219afea to your computer and use it in GitHub Desktop.
Using the CORS module of node for dynamic origins
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var cors = require('cors') | |
var whitelist = ['http://localhost:4000','http://someotherserver.com']; | |
var corsOptions = { | |
origin: function(origin, callback){ | |
var originIsWhitelisted = whitelist.indexOf(origin) !== -1; | |
callback(null, originIsWhitelisted); | |
} | |
}; | |
app.options('/chans',cors(corsOptions)) | |
app.put('/chans',cors(),function(req,resp){ | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment