Skip to content

Instantly share code, notes, and snippets.

@jrowny
Created August 8, 2013 16:41
Show Gist options
  • Select an option

  • Save jrowny/6186325 to your computer and use it in GitHub Desktop.

Select an option

Save jrowny/6186325 to your computer and use it in GitHub Desktop.
A quick "serve this folder" express web server that has CORS way open. TEST ONLY don't you dare use this in production.
var express = require('express'),
app = express();
app.use(express.methodOverride());
app.use(express.bodyParser());
app.use(function(req, res, next) {
res.header("Access-Control-Allow-Origin", "*");
res.header("Access-Control-Allow-Headers", "X-Requested-With, origin, x-csrftoken, content-type, accept");
res.header("Access-Control-Allow-Methods", "POST, GET, PUT, DELETE, OPTIONS");
next();
});
app.use(express.static(__dirname));
app.listen(3002);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment