Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@ben-ng
Created July 17, 2013 02:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ben-ng/6017181 to your computer and use it in GitHub Desktop.
Save ben-ng/6017181 to your computer and use it in GitHub Desktop.
CORS before action
exports.allow = function(resp, req) {
if(!resp.headersSent) {
resp.setHeader('Access-Control-Allow-Origin', req.headers.origin)
resp.setHeader('Access-Control-Allow-Methods', 'GET,PUT,POST,DELETE,OPTIONS');
resp.setHeader('Access-Control-Allow-Credentials', 'true');
resp.setHeader('Access-Control-Allow-Headers', 'Content-Type');
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment