forked from Code4SocialGood/c4sg-web
-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
32 lines (24 loc) · 797 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
// see https://medium.com/@ryanchenkie_40935/angular-cli-deployment-host-your-angular-2-app-on-heroku-3f266f13f352
// for more information
const express = require('express');
const path = require('path');
const app = express();
// force SSL
const forceSSL = function () {
return function (req, res, next) {
if (req.headers['x-forwarded-proto'] !== 'https') {
return res.redirect(
['https://', req.get('Host'), req.url].join('')
);
}
next();
};
};
// instruct app to use forceSSL middleware
// todo: enable this when SSL is enabled for the servers
// app.use(forceSSL());
app.use(express.static(__dirname + '/dist'));
app.get('/*', function(req, res) {
res.sendFile(path.join(__dirname + '/dist/index.html'));
});
app.listen(process.env.PORT || 8080);