-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.js
26 lines (22 loc) · 890 Bytes
/
server.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
var express = require('express');
var path = require('path');
var app = express();
//app.use(express.static(__dirname)); // Current directory is root
app.use(express.static(path.join(__dirname, 'Source')));
app.use(function(req, res, next) {
res.header("Access-Control-Allow-Origin", "*");
res.header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept");
next();
});
app.use(function (req, res, next) {
res.setHeader('Access-Control-Allow-Origin', '*');
res.setHeader('Access-Control-Allow-Methods', 'GET, POST, OPTIONS, PUT, PATCH, DELETE');
res.setHeader('Access-Control-Allow-Headers', 'X-Requested-With,content-type');
res.setHeader('Access-Control-Allow-Credentials', true);
next();
});
app.get('/', function(req, res, next) {
res.send('index.html');
});
app.listen(process.env.PORT ||5000);
console.log('Listening on port 5000!');