Skip to content

Instantly share code, notes, and snippets.

@sguzman
Created November 23, 2017 20:27
Show Gist options
  • Save sguzman/31919b6e7c85715323c8766fd222cef3 to your computer and use it in GitHub Desktop.
Save sguzman/31919b6e7c85715323c8766fd222cef3 to your computer and use it in GitHub Desktop.
Settings cors headers on express.js
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