Skip to content

Instantly share code, notes, and snippets.

@berat
Created May 18, 2020 12:43
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save berat/e0f72f8e5992053c0b1ed560f36f2988 to your computer and use it in GitHub Desktop.
var whitelist = [
'https://site2.com',
'http://site1.com',
'http://0.0.0.0:3000'
]
var corsOptions = {
origin: function(origin, callback) {
var originIsWhitelisted = whitelist.indexOf(origin) !== -1
callback(null, originIsWhitelisted)
},
credentials: true
}
app.use(cors(corsOptions))
app.options('*', cors())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment