Skip to content

Instantly share code, notes, and snippets.

@ruzzbot
Created November 1, 2012 22:43
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save ruzzbot/3997190 to your computer and use it in GitHub Desktop.
Save ruzzbot/3997190 to your computer and use it in GitHub Desktop.
express.js middleware to allow cross-domain access
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