-
-
Save farvisun/75fd1db16c70cee1ba12ee66cce63e83 to your computer and use it in GitHub Desktop.
Revisions
-
Jason revised this gist
Apr 9, 2012 . No changes.There are no files selected for viewing
-
Jason created this gist
Apr 9, 2012 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,19 @@ app.use(express.methodOverride()); // ## CORS middleware // // see: http://stackoverflow.com/questions/7067966/how-to-allow-cors-in-express-nodejs 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'); // intercept OPTIONS method if ('OPTIONS' == req.method) { res.send(200); } else { next(); } }; app.use(allowCrossDomain);