-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathserver.js
35 lines (30 loc) · 920 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
35
var express = require('express')
var cors = require('cors')
var server = express()
server.use(cors())
if (process.env.NODE_ENV == 'production') {
server.use(function (req, res, next) {
var schema = (req.headers['x-forwarded-proto'] || '').toLowerCase();
if (schema === 'https') {
next();
} else {
res.redirect('https://' + req.headers.host + req.url);
}
});
}
server.use('/facebook', function(req, resp) {
resp.redirect("https://www.facebook.com/devconftech/")
});
server.use('/instagram', function(req, resp) {
resp.redirect("https://www.instagram.com/devconftech/")
});
server.use('/', express.static('dist'));
server.get('/', function(req, resp) {
resp.sendFile('dist/index.html', {
root: __dirname
})
})
var port = process.env.PORT || 3000;
server.listen(port, function() {
console.log('escutando na porta: ' + port)
})