-
-
Save JimAllanson/e6c0de248e6e7142e26c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var express = require('express') | |
, http = require('http') | |
, path = require('path'); | |
var app = express(); | |
// all environments | |
app.set('port', process.env.PORT || 3000); | |
app.post('/', function(req,res){ | |
res.header("Access-Control-Allow-Origin","*"); | |
res.header("Access-Control-Allow-Headers","X-Requested-With"); | |
res.header("Access-Control-Allow-Methods","GET, POST"); | |
res.send({"hello":"world"}) | |
}) | |
app.options('*', function(req,res){ | |
res.header('Access-Control-Allow-Origin', '*'); | |
res.header('Access-Control-Allow-Methods', 'GET,PUT,POST,DELETE,OPTIONS'); | |
res.header('Access-Control-Allow-Headers', 'Content-Type, Authorization, Content-Length, X-Requested-With'); | |
res.send(200); | |
}); | |
http.createServer(app).listen(app.get('port'), function(){ | |
console.log('Express server listening on port ' + app.get('port')); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment