-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.js
34 lines (26 loc) · 938 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
27
28
29
30
31
32
33
34
const express = require('express');
const path = require('path');
const cors = require('cors');
const app = express();
// add this code
const whitelist = ['https://mysterious-reef.herokuapp.com', 'https://commedia-dell-arte.herokuapp.com', 'https://utilitary-services.herokuapp.com']; // list of allow domain
const corsOptions = {
origin: function (origin, callback) {
if (!origin) {
return callback(null, true);
}
if (whitelist.indexOf(origin) === -1) {
var msg = 'The CORS policy for this site does not ' +
'allow access from the specified Origin.';
return callback(new Error(msg), false);
}
return callback(null, true);
}
}
// end
app.use(cors(corsOptions));
app.use(express.static('./dist/'));
app.get('/',function(req,res){
res.sendFile(path.join(__dirname+'/dist/index.html'));
});
app.listen(process.env.PORT || 8080);