Skip to content

Instantly share code, notes, and snippets.

@rttomlinson
Created May 17, 2017 15:13
Show Gist options
  • Save rttomlinson/2b4ed39bc36d2aecdbc0e75a7f4c41e4 to your computer and use it in GitHub Desktop.
Save rttomlinson/2b4ed39bc36d2aecdbc0e75a7f4c41e4 to your computer and use it in GitHub Desktop.
Basic CORS Request Headers
//Set up CORS headers from client-side
app.use(function(req, res, next) {
res.header("Access-Control-Allow-Origin", "*");
res.header("Access-Control-Allow-Methods", "PUT, GET, POST, DELETE, OPTIONS");
res.header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept, Authorization, Access-Control-Allow-Credentials");
res.header("Access-Control-Allow-Credentials", "true");
next();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment