Created
October 1, 2012 20:39
-
-
Save jrask/3814285 to your computer and use it in GitHub Desktop.
CORS
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
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