Skip to content

Instantly share code, notes, and snippets.

@tomysmile
Created October 18, 2015 15:36
Show Gist options
  • Save tomysmile/8533b19ba8025f270347 to your computer and use it in GitHub Desktop.
Save tomysmile/8533b19ba8025f270347 to your computer and use it in GitHub Desktop.
Node: CORS acceptance

// Setup express

var app = express();
var server = require('http').createServer(app);

// CORS acceptance

app.use(function(req, res, next) {
  res.header("Access-Control-Allow-Origin", "*");
  res.header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept");
  next();
});

// your route definition
require('./routes')(app);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment