Skip to content

Instantly share code, notes, and snippets.

@jrask
Created October 1, 2012 20:39
Show Gist options
  • Save jrask/3814285 to your computer and use it in GitHub Desktop.
Save jrask/3814285 to your computer and use it in GitHub Desktop.
CORS
function handleCors(req, res, callback) {
res.setHeader('Access-Control-Allow-Origin', '*')
res.setHeader('Access-Control-Allow-Methods', 'GET, POST, PUT, DELETE,OPTIONS');
res.setHeader('Access-Control-Allow-Headers', 'Authorization');
// CORS OPTIONS request, simply return 200
if (req.method == 'OPTIONS') {
res.statusCode = 200;
res.end();
callback.onOptions();
return;
}
callback.onContinue();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment