Skip to content

Instantly share code, notes, and snippets.

@wizardnet972
Created October 30, 2016 17:24
Show Gist options
  • Save wizardnet972/69031008e8ad443d9b88d05e4a40f2da to your computer and use it in GitHub Desktop.
Save wizardnet972/69031008e8ad443d9b88d05e4a40f2da to your computer and use it in GitHub Desktop.
CORS on ExpressJS
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();
});
app.get('/', function(req, res, next) {
// Handle the get for this route
});
app.post('/', function(req, res, next) {
// Handle the post for this route
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment