Skip to content

Instantly share code, notes, and snippets.

@kharmabum
Created March 10, 2014 21:53
Show Gist options
  • Save kharmabum/9475246 to your computer and use it in GitHub Desktop.
Save kharmabum/9475246 to your computer and use it in GitHub Desktop.
var allowCrossDomain = function(req, res, next) {
res.header('Access-Control-Allow-Origin', '*');
res.header('Access-Control-Allow-Methods', 'GET,PUT,POST,DELETE');
res.header('Access-Control-Allow-Headers', 'Content-Type, Authorization');
if ('OPTIONS' == req.method) {
res.send(200);
}
else {
next();
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment