Skip to content

Instantly share code, notes, and snippets.

@agustinhaller
Created August 28, 2018 12:48
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 agustinhaller/cf200476a17350d7ffae9ae2278b17a0 to your computer and use it in GitHub Desktop.
Save agustinhaller/cf200476a17350d7ffae9ae2278b17a0 to your computer and use it in GitHub Desktop.
Simple express server
var express = require('express'),
app = express();
app.use(express.static('dist/browser'));
// CORS (Cross-Origin Resource Sharing) headers to support Cross-site HTTP requests
app.all('*', function(req, res, next) {
res.header("Access-Control-Allow-Origin", "*");
res.header("Access-Control-Allow-Headers", "X-Requested-With");
next();
});
app.set('port', process.env.PORT || 7000);
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