Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
var express = require('express')
,cors = require('cors')
, app = express();
// after the code that uses bodyParser and other cool stuff
var originsWhitelist = [
'http://localhost:4200', //this is my front-end url for development
var corsOptions = {
origin: function(origin, callback){
var isWhitelisted = originsWhitelist.indexOf(origin) !== -1;
callback(null, isWhitelisted);
//here is the magic
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.