Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save vuongtran/b6fc119ef1348e3c29fe to your computer and use it in GitHub Desktop.
Save vuongtran/b6fc119ef1348e3c29fe to your computer and use it in GitHub Desktop.
Config middleware to allow cross-domain access in express.js
var express = require('express'),
app = express();
app.use( function(req, res, next) {
res.header('Access-Control-Allow-Origin', '*');
res.header('Access-Control-Allow-Methods', 'GET,PUT,POST,DELETE,OPTIONS');
res.header('Access-Control-Allow-Headers', 'X-Requested-With, X-HTTP-Method-Override, Content-Type, Accept');
next();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment