Skip to content

Instantly share code, notes, and snippets.

@cahlan
Last active December 25, 2015 19:29
Show Gist options
  • Save cahlan/7027611 to your computer and use it in GitHub Desktop.
Save cahlan/7027611 to your computer and use it in GitHub Desktop.
app.get('/', function(req, res) {
res.type('application/json');
res.setHeader('Access-Control-Allow-Origin', '*');
res.send(JSON.stringify(messages));
});
app.post('/', function(req, res) {
messages.push(req.body);
res.send();
});
app.options('/', function(req, res) {
res.setHeader('Access-Control-Allow-Origin', '*');
res.setHeader('Access-Control-Allow-Methods', 'OPTIONS, GET, POST');
res.setHeader('Access-Control-Allow-Headers', 'Origin, X-Requested-With, Content-Type, Accept');
res.send();
})
app.listen(8888);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment