Skip to content

Instantly share code, notes, and snippets.

@chillax
Created August 5, 2014 07:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chillax/604d585309e216827e71 to your computer and use it in GitHub Desktop.
Save chillax/604d585309e216827e71 to your computer and use it in GitHub Desktop.
Express.js echo server with CORS support
var express = require('express');
var bodyParser = require('body-parser');
var app = express();
app.use(bodyParser.json())
app.all('/', function(req, res) {
res.header('Access-Control-Allow-Origin', '*');
res.header('Access-Control-Allow-Headers', 'Content-Type');
res.send(req.body);
});
app.listen(3000);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment