Skip to content

Instantly share code, notes, and snippets.

@ubergoober
Created December 30, 2014 11:32
Show Gist options
  • Select an option

  • Save ubergoober/6e1f05f4a16c7f617c89 to your computer and use it in GitHub Desktop.

Select an option

Save ubergoober/6e1f05f4a16c7f617c89 to your computer and use it in GitHub Desktop.
Express Node Server CORS
var app = express();
app.use(function (req, res, next) {
res.setHeader('Access-Control-Allow-Origin', req.headers.origin);
res.setHeader('Access-Control-Allow-Methods', 'GET, POST, OPTIONS, PUT, PATCH, DELETE');
res.setHeader('Access-Control-Allow-Headers', 'X-Requested-With,content-type');
next();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment