-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.js
38 lines (30 loc) · 1.04 KB
/
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
35
36
37
38
var express = require('express');
var cors = require('cors')
var app = express();
var path = require('path');
//Settings
app.set('port', process.env.PORT || 3000);
//Middlewares
app.use(express.json());
app.use(function (req, res, next) {
res.setHeader('Access-Control-Allow-Origin', 'http://valor-software.github.io');
res.setHeader('Access-Control-Allow-Methods', 'POST');
res.setHeader('Access-Control-Allow-Headers', 'X-Requested-With,content-type');
res.setHeader('Access-Control-Allow-Credentials', true);
next();
});
//var uri_origin = 'http://localhost:4200'
var uri_origin = ''
app.use(cors({origin: uri_origin}))
//Routes
app.use('/', require('./server/routes/api-spotify.route'));
if(process.env.NODE_ENV === 'production'){
app.use(express.static(__dirname + '/dist/falou-app'))
}
//Start server
app.get('*', function(req, res){
res.sendFile(path.join(__dirname,'/dist/falou-app','index.html'));
});
app.listen(process.env.PORT || 3000, () => {
console.log(`Server running`);
});